SocketStream
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#ifndef INCLUDED_C_SOCKET_H
|
||||
#define INCLUDED_C_SOCKET_H
|
||||
|
||||
#ifndef INCLUDED_C_TYPES_H
|
||||
#include <c_Types.h>
|
||||
#endif /*INCLUDED_C_TYPES_H*/
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include <winsock2.h>
|
||||
typedef SOCKET c_socket_t;
|
||||
#define C_INVALID_SOCKET INVALID_SOCKET
|
||||
#define C_SOCKET_ERROR SOCKET_ERROR
|
||||
#define c_Socket_Close(x) closesocket(x)
|
||||
|
||||
C_STATIC_FORCE_INLINE
|
||||
void c_Socket_Init(void) {
|
||||
WSADATA wsa; WSAStartup(MAKEWORD(2,2), &wsa);
|
||||
}
|
||||
|
||||
C_STATIC_FORCE_INLINE
|
||||
void c_Socket_Destroy(void) {
|
||||
WSACleanup();
|
||||
}
|
||||
#else
|
||||
typedef int c_socket_t;
|
||||
#define C_INVALID_SOCKET (-1)
|
||||
#define C_SOCKET_ERROR (-1)
|
||||
#define c_Socket_Close(x) close(x)
|
||||
#define c_Socket_Init()
|
||||
#define c_Socket_Destroy()
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /*INCLUDED_C_SOCKET_H*/
|
||||
Reference in New Issue
Block a user