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

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: 828 bytes
Line 
1/**
2 * @file socket_client.c
3 * @author myusgun <myusgun@gmail.com>
4 */
5#include "cf_socket.h"
6#include <stdio.h>
7#include <string.h>
8
9int main (void) {
10 int sock = 0;
11 int result = 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 fprintf (stderr, "error : connect (%d)\n", sock);
21 }
22
23 result = CF_Socket_Send (sock, buf, sizeof (buf));
24 if (result < 0) {
25 fprintf (stderr, "error : send (%d)\n", sock);
26 }
27 memset (buf, 0x00, strlen (buf));
28
29 result = CF_Socket_Recv (sock, buf, sizeof (buf));
30 if (result < 0) {
31 fprintf (stderr, "error : recv (%d)\n", result);
32 }
33 fprintf (stderr, "client recv : %s(%d)\n", buf, result);
34
35 CF_Socket_Close (sock);
36 CF_Socket_Finalize ();
37
38 return 0;
39}
Note: See TracBrowser for help on using the repository browser.