Rolling my own linux networking code..
Posted: Thu Dec 30, 2004 10:34 am
Hello everyone. I finally got around to getting the proper libraries and such installed on my debian box, to be able to start tinkering with network programming using PB, within Linux. I have been pleasantly surprised that there are certain API calls which I would require which seem to be recognized already by PB (most notably, socket_, and fcntl_.. enough to set up a non-blocking socket) So things were looking good.. so far.
Then after some further research, I noticed that the unfortunate downside is that certain constants required by these commands seem to be not defined. (Whereas the similar ones are, over in Windows PB land) I have gone to some lengths to find out which constants I will require, and have been able to find out where they have been declared in the libraries included with debian. The part where I am having a problem however, is after noting the following excerpt from '/usr/include/sys/socket.h' which states:
This is all fine and good, because I can just write my own constant definitions to use from my PB lib in calling the linux networking API functions, including this required constant as well as several others.. however the confusion begins when I cross-reference this with some online searching I had done (a la trusty Google) I had found this page: http://www.cs.ucl.ac.uk/staff/S.Bhatti/ ... c-sockets/
If you scroll down about half way through the page, it shows that whatever OS this is has an include <sys/socket.h>, which defines SOCK_DGRAM as being 1! (And SOCK_STREAM is 2.. ie the exact opposite of what I am seeing here on my debian box!)
This now obviously causes me some distress, as I am unable at least to my knowledge to include or process C header files in PB, and as such I have no way of knowing what proper value to pass to the API calls (such as socket_, etc) And me being such a newbie to linux.. I thought it best that perhaps I try to confirm these findings with my fellow linux pb'ers
(Hey if this gets sorted there could be a good networking lib in it for ya, hehe!)
Basically I just wanted to know if anybody else out there could check and see what the constants SOCK_DGRAM and SOCK_STREAM are defined on your system.. They should be defined somewhere around <sys/socket.h>, although if they are not there (as in my case), there should be another include mentioned in socket.h which will show you where to look.
Thanks in advance for any help
Then after some further research, I noticed that the unfortunate downside is that certain constants required by these commands seem to be not defined. (Whereas the similar ones are, over in Windows PB land) I have gone to some lengths to find out which constants I will require, and have been able to find out where they have been declared in the libraries included with debian. The part where I am having a problem however, is after noting the following excerpt from '/usr/include/sys/socket.h' which states:
Now after going through and looking at '/usr/include/bits/socket.h', I see SOCK_DGRAM being declared as "2". (I am only really looking at UDP because I am thinking of writing a cross-platform UDP library..)/* This operating system-specific header file defines the SOCK_*, PF_*,
AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr',
`struct msghdr', and `struct linger' types. */
#include [bits/socket.h] (angle brackets replaced by square brackets so as to not be parsed as html..)
This is all fine and good, because I can just write my own constant definitions to use from my PB lib in calling the linux networking API functions, including this required constant as well as several others.. however the confusion begins when I cross-reference this with some online searching I had done (a la trusty Google) I had found this page: http://www.cs.ucl.ac.uk/staff/S.Bhatti/ ... c-sockets/
If you scroll down about half way through the page, it shows that whatever OS this is has an include <sys/socket.h>, which defines SOCK_DGRAM as being 1! (And SOCK_STREAM is 2.. ie the exact opposite of what I am seeing here on my debian box!)
This now obviously causes me some distress, as I am unable at least to my knowledge to include or process C header files in PB, and as such I have no way of knowing what proper value to pass to the API calls (such as socket_, etc) And me being such a newbie to linux.. I thought it best that perhaps I try to confirm these findings with my fellow linux pb'ers

Basically I just wanted to know if anybody else out there could check and see what the constants SOCK_DGRAM and SOCK_STREAM are defined on your system.. They should be defined somewhere around <sys/socket.h>, although if they are not there (as in my case), there should be another include mentioned in socket.h which will show you where to look.
Thanks in advance for any help
