comparison 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
comparison
equal deleted inserted replaced
3:2758f5527d2b 4:0b3b4f5887bb
19 #include <signal.h> 19 #include <signal.h>
20 #include <fcntl.h> 20 #include <fcntl.h>
21 21
22 #include "dowa/dowa.h" 22 #include "dowa/dowa.h"
23 23
24 #define INITIAL_BUFFER_CAPACITY 4096
25
26 typedef struct {
27 int socket;
28 char *host;
29 char *port;
30
31 uint8 *read_buffer;
32 uint32 read_buffer_capacity;
33 uint32 read_buffer_len; // current size
34 uint32 read_buffer_pos; // TODO: Implement this for client
35
36 uint8 *write_buffer;
37 uint32 write_buffer_capacity;
38 uint32 write_buffer_len; // current size
39
40 void *file;
41 void *text_copy;
42 char *file_name;
43 } Sebeo_Handle, *Seobeo_PHandle;
44
24 45
25 // --- Internal? --- // 46 // --- Internal? --- //
26 extern int Seobeo_CreateSocket(int32 stream, char* port, int32 backlog); 47 extern int Seobeo_CreateSocket(int32 stream, const char *host, const char* port, int32 backlog);
27 extern void Seobeo_ListenClient(int sock_fd, void (*handle_client)(int)); 48 extern void *Seobeo_GetIP4OrIP6(struct sockaddr *sa);
28 extern void *Seobeo_GetIP4OrIP6(struct sockaddr *sa);
29 49
30 // --- TCP --- // 50 // --- TCP --- //
31 // extern int Seobeo_TCP_SocketCreate(char* port, int32 backlog) 51 extern Seobeo_PHandle Seobeo_Stream_Handle_Create(const char *host, const char* port);
52 extern Seobeo_PHandle Seobeo_Stream_Handle_Accept(Seobeo_PHandle server_h);
53 extern void Seobeo_Handle_Destroy(Seobeo_PHandle h);
54 extern int Seobeo_Handle_Flush(Seobeo_PHandle h);
55 extern int Seobeo_Handle_QueueData(Seobeo_PHandle h, const uint8_t *data, uint32_t data_size);
32 56
33 57
34 #endif 58 #endif