source: libcf/trunk/test/socket_client.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: 663 bytes
Line 
1/**
2 * @file socket_client.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 sock = 0;
11 int recvd = 0;
12 char buf[] = "http://unsigned.kr";
13 unsigned short port = 12345;
14
15 if (CF_Socket_Initialize () < 0) {
16 // error
17 }
18 sock = CF_Socket_Connect ("localhost", port);
19 if (sock < 0) {
20 // error
21 }
22 if (CF_Socket_Send (sock, buf, sizeof (buf)) < 0) {
23 // error
24 }
25 memset (buf, 0x00, strlen (buf));
26 if ((recvd = CF_Socket_Recv (sock, buf, sizeof (buf))) < 0) {
27 // error
28 }
29 fprintf (stderr, "client recv : %s\n", buf);
30 CF_Socket_Close (sock);
31 CF_Socket_Finalize ();
32
33 return 0;
34}
Note: See TracBrowser for help on using the repository browser.