thefull wrote:...y en la libreria de TIP de Harbour
He mirado la TIP y no me da soluciones, pero siguiendo la pista que me has dado he llegado a funciones de xHarbour de tratamiento multicast.
Pero me encuentro que no me "llenan" del todo en cuanto a posiblidades.
INetDGramBind(<nPort>,[<cIPAddress>],[<lBroadcast>],[<cMulticast>]) --> pSocket
Le falta el poder manejar las subscripciones multicast a gusto de las necesidades.
Asi por ejejmplo solo hace la IP_ADD_MEMBERSHIP para la subscripcion del flujo multicast deseado, pero no la IP_DROP_MEMBERSHIP para anular la subscripcion.
Ademas no maneja el TTL (IP_MULTICAST_TTL) que es el tiempo de vida de la trama (Time To Live).
Necesario el parametro TTL para poder controlar el "alcance" de la "emision" de las tramas multicast.
INetDGramSend(<pSocket>,<cIPAddress>,<nPort>,<cData>,[<nBytes>]) --> nSentBytes
No usa enrutamiento por tablas ARP. Aunque me serviria.
INetDGramRecv(<pSocket>,@<cBuffer>,[<nBytes>]) --> nReceivedBytes
Solo efectua el RECV del Win-API no el recvFROM con lo que si recibimos varias tramas multicast con la misma direccion IP destino y distintos origenes no podremos distingir su origen.
Antonio Linares wrote:Como te comenta Rafa, échale un vistazo a fwh\source\winapi\winsock.c
En cuanto al API-FW veo la falta de parametros que me serián necesarios.
En las funciones de winsock.c comparadas con el API de Windows pienso esto:
WSAStartup no admite párametros, la del WinAPI dos (Version y Buffer)
HTONS es la misma.
INET_ADDR es la misma.
Socket es la misma.
BINDTOPORT menos parametros.
RECV menos parametros y no existe la recvFROM.
SOCKETSEND/SENDBINARY menos parametros y no existe la sendTO.
SETSOCKOPT menos parametros y no existe la GETsockopt.
Yo lo que he hecho es WRAPEAR las funciones del API de Windows, en su mayoria de la wsock32.dll, en las que he dejado todos sus parametros disponibles.
Code: Select all
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 WORD 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 WORD 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"
DLL32 FUNCTION WSAGetLastError() AS LONG PASCAL FROM "WSAGetLastError" LIB "wsock32.dll"
Pero claro, casi todos los parametros AS LPSTR, son punteros a estructuras. Con o que hay que pasarles por referencia el buffer de la estructura.
Me funcionan de maravilla las estructuras del tipo:
#include "struct.ch"
#include "exstruc.ch"
STRUCT sockaddr
MEMBER s_family AS WORD
MEMBER s_port AS WORD
MEMBER s_addr AS LONG
MEMBER s_zero AS STRING LEN 8
ENDSTRUCT
Las tipo "C" me han dado problemas de manejo de buffers y de tipo de datos.
Por eso el poder crear arrays dentro de estructuras y estructuras anidades pero usando estos tipos de FW.
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