Getpeername() question

Getpeername() question

Postby byte-one » Mon May 02, 2016 9:47 am

The Getpeername() from FW accept a number as parameter. I use the Harbour-functions with inet*
Code: Select all  Expand view
pSocket := INetDGramBind( nPort , , .T. , cIP_M  
and these are using a pointer for the open socket. In which way i convert from pointer to number to use FW-function. Or is there a Harbour-getpeername() with pointer as parameter?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Getpeername() question

Postby Antonio Linares » Mon May 02, 2016 10:17 am

Günther,

> In which way i convert from pointer to number to use FW-function

PHB_SOCKET_STRUCT socket = HB_PARSOCKET( 1 );

it seems as socket->sd is the standard socket that FWH expects
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Getpeername() question

Postby byte-one » Mon May 02, 2016 8:07 pm

Antonio, thanks! I would use getpeername() to check if the connection is at the moment online. But in a datagram-socket gives the function not the current state but rather the ip from creation from the socket.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Getpeername() question

Postby Antonio Linares » Tue May 03, 2016 7:09 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Getpeername() question

Postby Antonio Linares » Tue May 03, 2016 7:12 am

This is also interesting:

http://stackoverflow.com/questions/15778404/programmatically-check-whether-my-machine-has-internet-access-or-not

Code: Select all  Expand view
#include <iostream>
#include <windows.h>
#include <wininet.h>
using namespace std;

int main(){

if(InternetCheckConnection(L"http://www.google.com",FLAG_ICC_FORCE_CONNECTION,0))
{
        cout << "connected to internet";
}

return 0;
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Getpeername() question

Postby byte-one » Tue May 03, 2016 8:08 pm

Thanks Antonio!
In my case with a multicast-socket i only receive messages over the local LAN. This messages comes from time to time. The manufacturer from the hardware says to me, that all maximal 10 seconds the message is refreshed. So i wait maximal this 10 seconds and when no message received in this time i show the message: OFFLINE. This is for me enough information for the user.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Getpeername() question

Postby Antonio Linares » Wed May 04, 2016 8:33 am

very good
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 45 guests