annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1 #ifndef SEOBEO_SERVER_H
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2 #define SEOBEO_SERVER_H
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4 // --- Seobeo --- //
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5 // Library for creating sockets, binding sockets, and listening to a sockets.
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
6 // Sending and unpacking bytes of data.
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
7
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
8 #include <stdio.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
9 #include <stdlib.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
10 #include <unistd.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
11 #include <errno.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
12 #include <string.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
13 #include <sys/types.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
14 #include <sys/socket.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
15 #include <netinet/in.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
16 #include <netdb.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
17 #include <arpa/inet.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
18 #include <sys/wait.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
19 #include <signal.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
20 #include <fcntl.h>
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
21
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
22 #include "dowa/dowa.h"
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
23
4
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
24 #define INITIAL_BUFFER_CAPACITY 4096
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
25
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
26 typedef struct {
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
27 int socket;
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
28 char *host;
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
29 char *port;
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
30
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
31 uint8 *read_buffer;
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
32 uint32 read_buffer_capacity;
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
33 uint32 read_buffer_len; // current size
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
34 uint32 read_buffer_pos; // TODO: Implement this for client
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
35
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
36 uint8 *write_buffer;
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
37 uint32 write_buffer_capacity;
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
38 uint32 write_buffer_len; // current size
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
39
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
40 void *file;
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
41 void *text_copy;
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
42 char *file_name;
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
43 } Sebeo_Handle, *Seobeo_PHandle;
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
44
1
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
45
3
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
46 // --- Internal? --- //
4
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
47 extern int Seobeo_CreateSocket(int32 stream, const char *host, const char* port, int32 backlog);
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
48 extern void *Seobeo_GetIP4OrIP6(struct sockaddr *sa);
3
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
49
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
50 // --- TCP --- //
4
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
51 extern Seobeo_PHandle Seobeo_Stream_Handle_Create(const char *host, const char* port);
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
52 extern Seobeo_PHandle Seobeo_Stream_Handle_Accept(Seobeo_PHandle server_h);
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
53 extern void Seobeo_Handle_Destroy(Seobeo_PHandle h);
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
54 extern int Seobeo_Handle_Flush(Seobeo_PHandle h);
0b3b4f5887bb [Seobeo] Updated so that it create socket for both server and clients.
June Park <parkjune1995@gmail.com>
parents: 3
diff changeset
55 extern int Seobeo_Handle_QueueData(Seobeo_PHandle h, const uint8_t *data, uint32_t data_size);
3
2758f5527d2b [Seobeo] Working on simple TCP server and client logic.
June Park <parkjune1995@gmail.com>
parents: 1
diff changeset
56
1
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
57
adcfad6e86fb Updated naming and separated out some logic within seobeo.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
58 #endif