Last change
on this file since 46 was 46, checked in by cheese, 11 years ago |
#1 change timeout mechanism from setting socket option to using select
|
File size:
845 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 |
|
---|
10 | int main (void) {
|
---|
11 | int sock = 0;
|
---|
12 | int result = 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 | fprintf (stderr, "error : connect (%d)\n", sock);
|
---|
22 | }
|
---|
23 |
|
---|
24 | result = CF_Socket_Send (sock, buf, sizeof (buf));
|
---|
25 | if (result < 0) {
|
---|
26 | fprintf (stderr, "error : send (%d)\n", sock);
|
---|
27 | }
|
---|
28 | memset (buf, 0x00, strlen (buf));
|
---|
29 |
|
---|
30 | result = CF_Socket_Recv (sock, buf, sizeof (buf));
|
---|
31 | if (result < 0) {
|
---|
32 | fprintf (stderr, "error : recv (%d)\n", result);
|
---|
33 | }
|
---|
34 | fprintf (stderr, "client recv : %s(%d)\n", buf,, result);
|
---|
35 |
|
---|
36 | CF_Socket_Close (sock);
|
---|
37 | CF_Socket_Finalize ();
|
---|
38 |
|
---|
39 | return 0;
|
---|
40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.