project_files/frontlib/ipc/ipcconn.c
changeset 7227 1c859f572d72
parent 7224 5143861c83bd
equal deleted inserted replaced
7224:5143861c83bd 7227:1c859f572d72
    13  * the messages are at most 256 bytes, but the map preview contains 4097 bytes (4096 for a
    13  * the messages are at most 256 bytes, but the map preview contains 4097 bytes (4096 for a
    14  * bitmap, 1 for the number of hogs which fit on the map).
    14  * bitmap, 1 for the number of hogs which fit on the map).
    15  *
    15  *
    16  * We don't need to worry about wasting a few kb though, and I like powers of two...
    16  * We don't need to worry about wasting a few kb though, and I like powers of two...
    17  */
    17  */
    18 typedef struct _flib_ipcconn {
    18 struct _flib_ipcconn {
    19 	uint8_t readBuffer[8192];
    19 	uint8_t readBuffer[8192];
    20 	int readBufferSize;
    20 	int readBufferSize;
    21 
    21 
    22 	flib_acceptor *acceptor;
    22 	flib_acceptor *acceptor;
    23 	uint16_t port;
    23 	uint16_t port;
    24 
    24 
    25 	flib_tcpsocket *sock;
    25 	flib_tcpsocket *sock;
    26 } _flib_ipcconn;
    26 };
    27 
    27 
    28 flib_ipcconn *flib_ipcconn_create() {
    28 flib_ipcconn *flib_ipcconn_create() {
    29 	flib_ipcconn *result = flib_malloc(sizeof(_flib_ipcconn));
    29 	flib_ipcconn *result = flib_malloc(sizeof(flib_ipcconn));
    30 	flib_acceptor *acceptor = flib_acceptor_create(0);
    30 	flib_acceptor *acceptor = flib_acceptor_create(0);
    31 
    31 
    32 	if(!result || !acceptor) {
    32 	if(!result || !acceptor) {
    33 		free(result);
    33 		free(result);
    34 		flib_acceptor_close(acceptor);
    34 		flib_acceptor_close(acceptor);