Feature request > Network

SOCK_RECVIP - Possible?

<< < (2/4) > >>

Kitty Hello:
there's no header IIRC. You can browse the web to see if you find something usefull. I can implement that.

This one has some related stuff too:


And yes it should be possible to see where a packet came from even with UDP.

I've looked up stuff regarding winsock.  I'm not sure what is used internally for networking in GLBasic, but Winsock seems to output a structure after receiving a UDP message which contains info (the 'recvfrom' structure is a 'sockaddr' structure, see http://msdn.microsoft.com/en-us/library/ms740496%28v=VS.85%29.aspx, which contains the IP address).

The 'recvfrom' function seems to be used in UDP (it says it is used for connectionless receiving) - see http://msdn.microsoft.com/en-us/library/ms740120%28v=VS.85%29.aspx
This function outputs a sockaddr structure:

--- Code: (glbasic) ---int recvfrom(
  __in         SOCKET s,
  __out        char *buf,
  __in         int len,
  __in         int flags,
  __out        struct sockaddr *from,
  __inout_opt  int *fromlen
--- End code ---

The 'recvfrom' function, or something similar seems to be used in GLBasic.  This function takes in a previously setup socket, a pointer to a buffer, a maximum length to read - sounds like the the GL function:

--- Code: (glbasic) ---SOCK_RECV(sock%,msg$,length%)
--- End code ---

Anyway, if GLBasic does use Winsock, then the IP address from a received UDP message should be put in the specified 'sockaddr' structure.  However, I'm assuming it's probably a lot more complicated than that - Winsock doesn't exactly sound like a multiplatform thing  :D
I think that the majority of this post will probably be useless if GLBasic doesn't use winsock, and possibly if I've misunderstood stuff about winsock, but here are some links which should be relevant in any case:

The structure of 'pseudoheaders' - the source IP is included.  http://en.wikipedia.org/wiki/User_Datagram_Protocol#IPv4_PSEUDO-HEADER

If you scroll down to the section on UDP, you can see that there is a normal header, followed by the pseudoheader described in the wikipedia page (i think at least).  http://www.protocols.com/pbook/tcpip2.htm

Another link on the normal header and then IPv4 and IPv6 pseudoheaders.  http://www.networksorcery.com/enp/protocol/udp.htm

EDIT:  The links posted by Ocean and Moru also have this, I didn't notice until now :whistle:

Oh oh, I have always wanted ICMP, can we have that too while we are wishing? :-)

A support application. Istead of spelling out IPCONFIG, PING and TRACERT on the phone to confused customers that has problems with internet, I tell them to doubleclick the help_me.exe and tell me the result :-)

It's getting increasingly hard to explain to customers how to get to cmd.exe and I'm a bit tired of spending 30 minutes on this with people that just wants me to "fix internet" :-)

Would also be nice to write my own pingplotter :-)

Sadly it's not possible to harvest MAC adresses past the router but would like that too, if anyone knows how? :-)


[0] Message Index

[#] Next page

[*] Previous page

Go to full version