Mercurial
view seobeo/seobeo.h @ 4:0b3b4f5887bb
[Seobeo] Updated so that it create socket for both server and clients.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Fri, 26 Sep 2025 15:14:46 -0700 |
| parents | 2758f5527d2b |
| children | 3e12bf044589 |
line wrap: on
line source
#ifndef SEOBEO_SERVER_H #define SEOBEO_SERVER_H // --- Seobeo --- // // Library for creating sockets, binding sockets, and listening to a sockets. // Sending and unpacking bytes of data. #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <arpa/inet.h> #include <sys/wait.h> #include <signal.h> #include <fcntl.h> #include "dowa/dowa.h" #define INITIAL_BUFFER_CAPACITY 4096 typedef struct { int socket; char *host; char *port; uint8 *read_buffer; uint32 read_buffer_capacity; uint32 read_buffer_len; // current size uint32 read_buffer_pos; // TODO: Implement this for client uint8 *write_buffer; uint32 write_buffer_capacity; uint32 write_buffer_len; // current size void *file; void *text_copy; char *file_name; } Sebeo_Handle, *Seobeo_PHandle; // --- Internal? --- // extern int Seobeo_CreateSocket(int32 stream, const char *host, const char* port, int32 backlog); extern void *Seobeo_GetIP4OrIP6(struct sockaddr *sa); // --- TCP --- // extern Seobeo_PHandle Seobeo_Stream_Handle_Create(const char *host, const char* port); extern Seobeo_PHandle Seobeo_Stream_Handle_Accept(Seobeo_PHandle server_h); extern void Seobeo_Handle_Destroy(Seobeo_PHandle h); extern int Seobeo_Handle_Flush(Seobeo_PHandle h); extern int Seobeo_Handle_QueueData(Seobeo_PHandle h, const uint8_t *data, uint32_t data_size); #endif