Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add scaffold to test win32 build on *nix, improve readme, fix typo
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
# On Windows, add "-DWIN32" | |||
CC=gcc | |||
CFLAGS=-O3 -W -Wall -Wextra | |||
LIB=socketpair | |||
|
|||
all: $(LIB).o | |||
|
|||
dummy: # test win32 build on unix | |||
$(CC) -DWIN32 $(CFLAGS) -Idummy_headers -c -o $(LIB).dummy $(LIB).c | |||
rm $(LIB).dummy | |||
|
|||
clean:; rm $(LIB).o |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
typedef void* SOCKET; | |||
typedef unsigned int DWORD; | |||
#define WSA_FLAG_OVERLAPPED 1 | |||
extern void WSASetLastError(int); | |||
extern int WSAGetLastError(); | |||
#define WSAEINVAL 22 | |||
#define SOCKET_ERROR -1 | |||
#define AF_INET 33 | |||
#define SOCK_STREAM 44 | |||
#define IPPROTO_TCP 55 | |||
#define INVALID_SOCKET 0 | |||
extern void* socket(int, int, int); | |||
struct sockaddr_in { | |||
int sin_family; | |||
struct { unsigned s_addr; } sin_addr; | |||
unsigned short sin_port; | |||
}; | |||
struct sockaddr { int dummy; }; | |||
typedef unsigned socklen_t; | |||
#define SOL_SOCKET 66 | |||
#define SO_REUSEADDR 77 | |||
#define INADDR_LOOPBACK 88 | |||
extern int setsockopt(SOCKET, int, int, char*, unsigned); | |||
extern int bind(SOCKET, struct sockaddr*, unsigned); | |||
extern int getsockname(SOCKET, struct sockaddr*, socklen_t*); | |||
extern int listen(SOCKET, int); | |||
extern SOCKET WSASocket(int, int, int, void*, int, int); | |||
extern int connect(SOCKET, struct sockaddr*, unsigned); | |||
extern SOCKET accept(SOCKET, void*, void*); | |||
extern int closesocket(SOCKET); | |||
extern unsigned htonl(unsigned); |
Empty file.