Porting Winsock to Linux Sockets

前端 未结 4 926
盖世英雄少女心
盖世英雄少女心 2021-01-11 15:56

I have a program that does some networking using Winsock, and one of our requirements right now is to port over our program to Linux. The only thing stopping us from doing t

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-11 17:00

    The only calls that make porting difficult are the WSA* calls.

    WSAStartup() -> nop WSACleanup() -> nop

    Socket/setsockopt -> socket/setsockopt

    Under *nix, sockets are blocking by default and it's not necessary or possible to use that weird setsockopt call to fiddle with it.

    ioctlsocket -> ioctl

    Under *nix we don't like asynchronous sockets much and prefer to use the select() system call.

    ---- Rest of this answer seems only to apply to Win95 compatible winsock ----

    Unfortunately as the original socket() in Winsock was broken in some cases, you probably used WSASocket() and so have to convert those calls.

提交回复
热议问题