This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [B20] porting code from Unix to Windows NT


This problem looks like you are having some confusion about what is going
on here.  In the unix code(sun right?) some previous programmer decided 
to call a struct sockaddr_un, SOCKET.  This struct sockaddr_un is used in 
bind, and connect calls to specify who/what/how you want to talk to another
socket.  The socket itself is considered to be a int( do a man on socket ).  
This int is used to identify what actual socket the operating system has
assigned
you(you get this from the socket call ).  In the windows world they decided to
call the socket descriptor, that you get back from the socket() call SOCKET.
This is the conflict that you are seeing.  You need to take the 
typedef struct sockaddr_un SOCKET;
code, and make it something like:
typedef struct sockaddr_un SOCKADDR;
Also replacing all occurrences of SOCKET for SOCKADDR.  Test this 
code in unix world to ensure before you move back over to windows.

Also I don't think windows supports the struct sockaddr_un type.  
I would check this out.  If it doesn't I would recommend using the:
struct sockaddr_in in it's place.  If you need examples of how to use
sockets in your code, I would recommend this book:
Unix Network Programming, by W.Richards Stevens ISBN: 0-13-949876-1
It talks about these things at great length.

Don't hesitate to ask me some more questions though if you have
any more questions....

donald
2)  Regular Sockets
At 01:57 PM 11/30/98 +0100, you wrote:
>hello
>I'm trying to port some Unix code to Windows Nt with Cygwin tools. My
>problem is that code handles sockets and I can't compile the source.
>I've put #define Win32_winsock and #include 'windows.h' in my source.
>But in my Unix code (somebody else wrote it, not me... I'm novice with
>unix ans C programming) SOCKET is defined like this :
>
>typedef struct sockaddr_un SOCKET;
>
>sockaddr_un is defined in sys/un.h like this :
>/*
> * definitions for Unix IPC domain.
>*/
>#if defined(_SOCKADDR_LEN) || defined(_KERNEL) ||
>defined(_XOPEN_SOURCE_EXTENDED)
>struct sockaddr_un {
>    unsigned char sun_len;
>    sa_family_t     sun_family;
>    char sun_path[104];
>};
>#else
>struct sockaddr_un {
>    unsigned short  sun_familly;
>    char sun_path[104];
>}
>#endif
>
>
>my unix code uses sun_path and sun_family...
>
>in Sockets.h (cygwin), SOCKETis defined as an unsigned int
>
>Did anybody have the same problem ? Can anybody help me ?
>Thanks
>
>--
>stagiaire projet CODES (INRIA ROCQUENCOURT)
>Christine.Pourcelot@inria.fr
>
>
>-
>For help on using this list (especially unsubscribing), send a message to
>"gnu-win32-request@cygnus.com" with one line of text: "help".
>

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]