Last change
on this file since 66 was 66, checked in by cheese, 11 years ago |
#1 add codec module (bin <-> hex-string)
|
File size:
910 bytes
|
Line | |
---|
1 | /**
|
---|
2 | * @file socket_server.c
|
---|
3 | * @author myusgun <myusgun@gmail.com>
|
---|
4 | */
|
---|
5 | #include "cf_socket.h"
|
---|
6 | #include <stdio.h>
|
---|
7 |
|
---|
8 | int main (void) {
|
---|
9 | int srvsock = 0;
|
---|
10 | int clntsock = 0;
|
---|
11 | unsigned short port = 12345;
|
---|
12 | int result = 0;
|
---|
13 | char buf[1024] = {0x00,};
|
---|
14 |
|
---|
15 | if (CF_Socket_Initialize () < 0) {
|
---|
16 | // error
|
---|
17 | }
|
---|
18 | srvsock = CF_Socket_Server (port, 5);
|
---|
19 | if (srvsock < 0) {
|
---|
20 | fprintf (stderr, "error : server (%d)\n", srvsock);
|
---|
21 | }
|
---|
22 |
|
---|
23 | clntsock = CF_Socket_Accept (srvsock);
|
---|
24 | if (clntsock < 0) {
|
---|
25 | fprintf (stderr, "error : accept (%d)\n", clntsock);
|
---|
26 | }
|
---|
27 |
|
---|
28 | result = CF_Socket_Recv (clntsock, buf, sizeof (buf));
|
---|
29 | if (result < 0) {
|
---|
30 | fprintf (stderr, "error : recv (%d)\n", result);
|
---|
31 | }
|
---|
32 | fprintf (stderr, "server recv : %s(%d)\n", buf, result);
|
---|
33 |
|
---|
34 | result = CF_Socket_Send (clntsock, buf, result);
|
---|
35 | if (result < 0) {
|
---|
36 | fprintf (stderr, "error : send (%d)\n", result);
|
---|
37 | }
|
---|
38 |
|
---|
39 | CF_Socket_Close (srvsock);
|
---|
40 | CF_Socket_Finalize ();
|
---|
41 |
|
---|
42 | return 0;
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.