source: libcf/trunk/test/socket_client.c@ 39

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

#1 fix socket_client test code

File size: 683 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#include <string.h>
9
10int main (void) {
11 int sock = 0;
12 int recvd = 0;
13 char buf[] = "http://unsigned.kr";
14 unsigned short port = 12345;
15
16 if (CF_Socket_Initialize () < 0) {
17 // error
18 }
19 sock = CF_Socket_Connect ("localhost", port);
20 if (sock < 0) {
21 // error
22 }
23 if (CF_Socket_Send (sock, buf, sizeof (buf)) < 0) {
24 // error
25 }
26 memset (buf, 0x00, strlen (buf));
27 if ((recvd = CF_Socket_Recv (sock, buf, sizeof (buf))) < 0) {
28 // error
29 }
30 fprintf (stderr, "client recv : %s\n", buf);
31 CF_Socket_Close (sock);
32 CF_Socket_Finalize ();
33
34 return 0;
35}
Note: See TracBrowser for help on using the repository browser.