Fivewin for for Pocket PC - April 2007 Harbour development power
Compiling...
Harbour devel build 1.1-1 Intl.
Copyright 1999-2007, http://www.harbour-project.org/
Compiling 'tudpsocket.prg' and generating preprocessed output to 'tudpsocket.ppo'...
Generating C source output to 'tudpsocket.c'... Done.
tudpsocket.c
Creating library tudpsocket.lib and object tudpsocket.exp
tudpsocket.obj : error LNK2001: unresolved external symbol HB_FUN_FW_GT
tudpsocket.exe : fatal error LNK1120: 1 unresolved externals
* Application successfully built
Code: Select all
#pragma BEGINDUMP
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbdefs.h"
#include "windows.h"
#include <WinSock2.h>
//----------------------------------------------------------------------------//
HB_FUNC( SENDUDP )
{
struct sockaddr_in sa ;
int wLen = hb_parclen( 2 );
memset( &sa, 0, sizeof( sa ) ); // _bset
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = inet_addr( hb_parc( 3 ) ); // INADDR_BROADCAST ;
sa.sin_port = htons( hb_parni( 4 ) );
hb_retni( sendto( hb_parni( 1 ), hb_parc( 2 ), wLen, 0,
( struct sockaddr * ) &sa, sizeof( sa ) ) );
}
/*-----------------------------------------------------------------------------------*/
HB_FUNC( RECVUDP )
{
struct sockaddr_in sa;
LPBYTE buffer = (LPBYTE)hb_xgrab( 8192 );
int nLen = sizeof( sa );
int wLen;
memset( &sa, 0, sizeof( sa ) ); // _bset
sa.sin_family = AF_INET;
// sa.sin_addr.s_addr = inet_addr( hb_parc( 3 ) );
sa.sin_addr.s_addr = htonl( INADDR_ANY );
wLen = recvfrom( hb_parni( 1 ), (char *)buffer, 8192, 0, ( struct sockaddr * ) &sa, &nLen );
if( wLen < 10000 )
hb_storclen( (char*)buffer, wLen, 2 );
else
hb_storclen( "", 0, 2 );
hb_storc( inet_ntoa( sa.sin_addr ), 3 );
hb_storni( htons( sa.sin_port ), 4 );
hb_retni( wLen );
hb_xfree( buffer );
}
/*-----------------------------------------------------------------------------------*/
HB_FUNC( REMOTEPORT ) // nSocket
{
struct sockaddr_in sa;
int iLen = sizeof( sa );
memset( &sa, 0, sizeof( sa ) );
getpeername( hb_parni( 1 ), ( struct sockaddr * ) &sa, &iLen );
hb_retni( ntohs( sa.sin_port ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( REMOTEIP ) // nSocket
{
struct sockaddr_in sa;
int iLen = sizeof( sa );
memset( &sa, 0, sizeof( sa ) );
getpeername( hb_parni( 1 ), ( struct sockaddr * ) &sa, &iLen );
hb_retc( inet_ntoa( sa.sin_addr ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( BINDTOADDR ) // nSocket, nPort, cAddr
{
struct sockaddr_in sa; // sockaddr_in sa;
memset( &sa, 0, sizeof( sa ) );
sa.sin_family = AF_INET;
sa.sin_port = htons( hb_parni( 2 ) );
sa.sin_addr.s_addr = inet_addr( hb_parc( 3 ) );
hb_retl( bind( hb_parni( 1 ), ( struct sockaddr * ) &sa, sizeof( sa ) ) == 0 );
}
#pragma ENDDUMP