Debian Codegraph @

src/core/util_network.h

raw symbols SCIP
1 /*----------------------------------------------------------------------------
2 ChucK Strongly-timed Audio Programming Language
3 Compiler, Virtual Machine, and Synthesis Engine
4
5 Copyright (c) 2003 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.stanford.edu/
7 http://chuck.cs.princeton.edu/
8
9 This program is free software; you can redistribute it and/or modify
10 it under the dual-license terms of EITHER the MIT License OR the GNU
11 General Public License (the latter as published by the Free Software
12 Foundation; either version 2 of the License or, at your option, any
13 later version).
14
15 This program is distributed in the hope that it will be useful and/or
16 interesting, but WITHOUT ANY WARRANTY; without even the implied warranty
17 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 MIT Licence and/or the GNU General Public License for details.
19
20 You should have received a copy of the MIT License and the GNU General
21 Public License (GPL) along with this program; a copy of the GPL can also
22 be obtained by writing to the Free Software Foundation, Inc., 59 Temple
23 Place, Suite 330, Boston, MA 02111-1307 U.S.A.
24 -----------------------------------------------------------------------------*/
25
26 //-----------------------------------------------------------------------------
27 // name: util_network.h
28 // desc: sockets
29 //
30 // author: Ge Wang ([email protected])
31 //
32 // originally 'randy_socket'
33 // author: Peng Bi ([email protected])
34 // Ge Wang ([email protected])
35 // date: Winter 2003
36 //-----------------------------------------------------------------------------
37 #ifndef __UTIL_NETWORK_H__
38 #define __UTIL_NETWORK_H__
39
40 #include "chuck_def.h"
41
42 #ifndef __PLATFORM_WINDOWS__
43 #include <sys/types.h>
44 #include <sys/socket.h>
45 #include <netinet/in.h>
46 #else
47 #define _WINSOCKAPI_
48 #include <windows.h>
49 #endif
50
51 #include "chuck_def.h"
52
53
54 #if defined(_cplusplus) || defined(__cplusplus)
55 extern "C" {
56 #endif
57
58 // our socket type
59 typedef struct ck_socket_ * ck_socket;
60
61 // create a UDP socket
62 ck_socket ck_udp_create( );
63 // create a TCP socket
64 ck_socket ck_tcp_create( int flags );
65 // connect to a server
66 t_CKBOOL ck_connect( ck_socket sock, const char * hostname, int port );
67 // connect to a server
68 t_CKBOOL ck_connect2( ck_socket sock, const struct sockaddr * serv_addr,
69 int addrlen);
70 // bind to a port
71 t_CKBOOL ck_bind( ck_socket sock, int port );
72 // listen (TCP)
73 t_CKBOOL ck_listen( ck_socket sock, int backlog );
74 // accept (TCP)
75 ck_socket ck_accept( ck_socket sock );
76
77 // send
78 int ck_send( ck_socket sock, const char * buffer, int len );
79 // send using connect/sendto
80 int ck_send2( ck_socket sock, const char * buffer, int len );
81 // send a datagram
82 int ck_sendto( ck_socket sock, const char * buffer, int len,
83 const struct sockaddr * to, int tolen );
84
85 // recv
86 int ck_recv( ck_socket sock, char * buffer, int len );
87 // recv
88 int ck_recv2( ck_socket sock, char * buffer, int len );
89 // recv a datagram
90 int ck_recvfrom( ck_socket sock, char * buffer, int len,
91 struct sockaddr * from, int * fromlen );
92
93 // send timeout
94 int ck_send_timeout( ck_socket sock, long sec, long usec );
95 // recv timeout
96 int ck_recv_timeout( ck_socket sock, long sec, long usec );
97
98 // close the socket
99 void ck_close( ck_socket sock );
100
101
102 #if defined(_cplusplus) || defined(__cplusplus)
103 }
104 #endif
105
106
107
108
109 #endif