Antonio Linares wrote:...por lo que podrías hacerlo como lo haces en el PC
En el PC lo hago todo WRAPEANDO las funciones...
Y ademas uso ESTRUCTURAS de datos.
¿ Seguro que esto mismo me funcionará ?
Ejemplos de codigos de estructuras:
STRUCT sockaddr
MEMBER s_family AS _INT
MEMBER s_port AS _INT
MEMBER s_addr AS LONG
MEMBER s_zero AS STRING LEN 8
ENDSTRUCT
STRUCT WSAData
MEMBER wVersion AS _INT
MEMBER wHighVer AS _INT
MEMBER szDescrip AS STRING LEN WSADESCRIPTION_LEN
MEMBER szSystem AS STRING LEN WSASYS_STATUS_LEN
MEMBER iMaxSock AS _INT
MEMBER iMaxUdpDg AS _INT
MEMBER lpVendor AS LONG
ENDSTRUCT
STRUCT ip_mreq
MEMBER i_multia AS LONG
MEMBER i_interf AS LONG
ENDSTRUCT
STRUCT Startup
MEMBER wVersion AS _INT
MEMBER wHighVer AS _INT
MEMBER szDescrip AS STRING LEN WSADESCRIPTION_LEN
MEMBER szSystem AS STRING LEN WSASYS_STATUS_LEN
MEMBER iMaxSock AS _INT
MEMBER iMaxUdpDg AS _INT
MEMBER lpVendor AS LONG
ENDSTRUCT
Ejemplos del wrapeo:
DLL32 FUNCTION WSAStartup(n AS LONG, pStruct AS LPSTR) AS LONG PASCAL FROM "WSAStartup" LIB "wsock32.dll"
DLL32 FUNCTION WSACleanup() AS LONG PASCAL FROM "WSACleanup" LIB "wsock32.dll"
DLL32 FUNCTION closesocket(af AS LONG) AS _INT PASCAL FROM "closesocket" LIB "wsock32.dll"
DLL32 FUNCTION MemCopy(dest AS LPSTR, src AS LPSTR, cb AS LONG ) AS VOID PASCAL FROM "RtlMoveMemory" LIB "Kernel32.dll"
DLL32 FUNCTION socket(af AS LONG, s_type AS LONG, protocol AS LONG ) AS LONG PASCAL FROM "socket" LIB "wsock32.dll"
DLL32 FUNCTION setsockopt(s AS LONG,level AS LONG,optname AS LONG,optval AS LPSTR,optlen AS LONG) AS LONG PASCAL FROM "setsockopt" LIB "wsock32.dll"
DLL32 FUNCTION getsockopt(s AS LONG,level AS LONG,optname AS LONG,optval AS LPSTR,optlen AS LONG) AS LONG PASCAL FROM "getsockopt" LIB "wsock32.dll"
DLL32 FUNCTION htonl(hostlong AS LONG) AS LONG PASCAL FROM "htonl" LIB "wsock32.dll"
DLL32 FUNCTION htons(hostshort AS LONG) AS _INT PASCAL FROM "htons" LIB "wsock32.dll"
DLL32 FUNCTION bind(s AS LONG, pStruct AS LPSTR,namelen AS LONG) AS LONG PASCAL FROM "bind" LIB "wsock32.dll"
DLL32 FUNCTION inet_addr(cp AS STRING) AS LONG PASCAL FROM "inet_addr" LIB "wsock32.dll"
DLL32 FUNCTION WSAAsyncSelect(s AS LONG, hWnd AS LONG, wMsg AS LONG, lEvent AS LONG) AS LONG PASCAL FROM "WSAAsyncSelect" LIB "wsock32.dll"
DLL32 FUNCTION recv(s AS LONG, Buf AS LPSTR, buflen AS LONG, flags AS LONG) AS LONG PASCAL FROM "recv" LIB "wsock32.dll"
DLL32 FUNCTION recvfrom(s AS LONG, Buf AS LPSTR, buflen AS LONG, flags AS LONG, addr As sockaddr, i AS LONG) AS LONG PASCAL FROM "recvfrom" LIB "wsock32.dll"
DLL32 FUNCTION send(s AS LONG, Buf AS LPSTR, buflen AS LONG, flags AS LONG) AS LONG PASCAL FROM "send" LIB "wsock32.dll"
DLL32 FUNCTION sendto(s AS LONG, Buf AS LPSTR, buflen AS LONG, flags AS LONG, addr AS LPSTR, i AS LONG) AS LONG PASCAL FROM "sendto" LIB "wsock32.dll"
Ejemplos de código:
sockaddr:s_family:=AF_INET
sockaddr:s_addr :=inet_addr(m_HostSet)
sockaddr:s_port :=htons(m_PortSet)
sockaddr:s_zero :=replicate(chr(0), 8 )
cTemp:=sockaddr:cBuffer
rc:=bind(SocketNum,@cTemp,sockaddr_size)
sockaddr:cBuffer:=cTemp
if rc<>0
MsgAlert("Fallo en BIND")
SocketNum:=-1
return nil
endif
stMreq2:i_interf:=inet_addr(m_HostSet)
cTemp:=stMreq2:cBuffer
rc:=setsockopt(SocketNum,IPPROTO_IP,IP_MULTICAST_IF,@cTemp,stMreq2:SizeOf())
stMreq2:cBuffer:=cTemp
if rc<>0
MsgAlert("Fallo en SETSOCKOPT-IF")
SocketNum:=-1
return nil
endif
Mi abuelo decía: Los aviones vuelan porque Dios quiere, y los helicópteros ni Dios sabe porque vuelan.
FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013