source: libcf/trunk/test/socket_server.c@ 35

Last change on this file since 35 was 35, checked in by cheese, 11 years ago

#1 separate example code and doxygen comment and fix logging push logic by vfire

File size: 721 bytes
Line 
1/**
2 * @file socket_server.c
3 * @author myusgun <myusgun@gmail.com>
4 * @version 0.1
5 */
6#include "cf_socket.h"
7#include <stdio.h>
8
9int main (void) {
10 int srvsock = 0;
11 int clntsock = 0;
12 unsigned short port = 12345;
13 int recvd = 0;
14 char buf[1024] = {0x00,};
15
16 if (CF_Socket_Initialize () < 0) {
17 // error
18 }
19 srvsock = CF_Socket_Server (port, 5);
20 if (srvsock < 0) {
21 // error
22 }
23 clntsock = CF_Socket_Accept (srvsock, NULL);
24 if (clntsock < 0) {
25 // error
26 }
27 if ((recvd = CF_Socket_Recv (clntsock, buf, sizeof (buf))) < 0) {
28 // error
29 }
30 fprintf (stderr, "server recv : %s\n", buf);
31 if (CF_Socket_Send (clntsock, buf, recvd) < 0) {
32 // error
33 }
34 CF_Socket_Close (srvsock);
35 CF_Socket_Finalize ();
36
37 return 0;
38}
Note: See TracBrowser for help on using the repository browser.