Archived

This topic is now archived and is closed to further replies.

CoMaNdore

Some winsocket questions

Recommended Posts

1. Where can i find a good, and small non-block chat server souce code? 2. When using bind: int bind( SOCKET s, const struct SOCK_ADDR *name, int namelen ); i have read in several diffrent tut that you call it like this: bind(some_socket,(LPSOCKADDR)&addr,sizeof(addr); why the LPSO..... thing ? 3. How can i read the packet header ?

Share this post


Link to post
Share on other sites
Hey,

1. Check out google.com and search for "chat server source Winsock". That should get you plenty of hits.

2. The (LPSOCKADDR) is just a type cast. Basically all LPSOCKADDR is is a typedef for (SOCKADDR *). The cast is required because of legacy issues with the way BSD socket address structures are named and formatted to support various protocols (namely UNIX domain sockets). Not a lot to know, except that you have to do it.

3. Explain what you mean by packet header. To which protocol layer are you referring? You can access the TCP segment headers by using raw sockets. You can access UDP packet headers the same way I believe. I''ve never had much reason to do either, unless I''m writing a packet sniffer. Even then, there are some nice libraries out there already to handle all of that...

Hope this helps.

Share this post


Link to post
Share on other sites