C-chat
sockets.h
Go to the documentation of this file.
1 
9 #ifndef C_CHAT_SOCKETS_H
10 #define C_CHAT_SOCKETS_H
11 
19 typedef struct Socket {
20  void* info;
21 } Socket;
22 
30 Socket createClientSocket(const char* ipAddress, const char* port);
31 
38 Socket createServerSocket(const char* port);
39 
46 Socket acceptClient(Socket serverSocket);
47 
56 int receiveFrom(Socket clientSocket, char* buffer, unsigned int bufferSize);
57 
66 int sendTo(Socket clientSocket, const char* buffer, unsigned int bufferSize);
67 
73 void closeSocket(Socket* socket);
74 
78 void cleanUp();
79 
80 #endif //C_CHAT_PACKETS_H
cleanUp
void cleanUp()
Performs any required resources cleanup. Must be called once all sockets usage is finished.
closeSocket
void closeSocket(Socket *socket)
Closes the given socket.
receiveFrom
int receiveFrom(Socket clientSocket, char *buffer, unsigned int bufferSize)
Receives through from the given socket.
Socket
Information of a socket.
Definition: sockets.h:19
acceptClient
Socket acceptClient(Socket serverSocket)
Waits for a client to connect to the given server socket. Returns the socket for the connected client...
createServerSocket
Socket createServerSocket(const char *port)
Creates a socket meant to receive connection from clients sockets.
sendTo
int sendTo(Socket clientSocket, const char *buffer, unsigned int bufferSize)
Sends data through the given socket.
createClientSocket
Socket createClientSocket(const char *ipAddress, const char *port)
Creates a socket meant to be used to connect to a server socket and initialize a connection with the ...