/[svn]/liblscp/trunk/lscp/socket.h
ViewVC logotype

Annotation of /liblscp/trunk/lscp/socket.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 114 - (hide annotations) (download) (as text)
Mon Jun 7 21:40:23 2004 UTC (19 years, 10 months ago) by capela
File MIME type: text/x-c++hdr
File size: 2693 byte(s)
* New lscp_socket_herror() wraper function
  for proper gethostbyname() error messages.

1 capela 62 // socket.h
2     //
3     /****************************************************************************
4     liblscp - LinuxSampler Control Protocol API
5     Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.
6    
7     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Lesser General Public
9     License as published by the Free Software Foundation; either
10     version 2.1 of the License, or (at your option) any later version.
11    
12     This library is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15     Lesser General Public License for more details.
16    
17     You should have received a copy of the GNU Lesser General Public
18     License along with this library; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20    
21     *****************************************************************************/
22    
23     #ifndef __LSCP_SOCKET_H
24     #define __LSCP_SOCKET_H
25    
26     #include "lscp/thread.h"
27    
28     #if defined(WIN32)
29     #include <winsock.h>
30     #else
31     #include <unistd.h>
32     #include <sys/socket.h>
33     #include <netinet/in.h>
34     #include <netinet/tcp.h>
35     #include <arpa/inet.h>
36     #include <netdb.h>
37     #endif
38    
39     #if defined(__cplusplus)
40     extern "C" {
41     #endif
42    
43     //-------------------------------------------------------------------------
44     // Sockets.
45    
46     #if defined(WIN32)
47     typedef SOCKET lscp_socket_t;
48     #else
49     typedef int lscp_socket_t;
50     #define INVALID_SOCKET -1
51     #define SOCKET_ERROR -1
52     #define closesocket(s) close(s)
53     #endif
54    
55     #define LSCP_BUFSIZ 1024
56    
57     void lscp_socket_perror (const char *pszPrefix);
58 capela 114 void lscp_socket_herror (const char *pszPrefix);
59 capela 62
60     void lscp_socket_getopts (const char *pszPrefix, lscp_socket_t sock);
61     void lscp_socket_trace (const char *pszPrefix, struct sockaddr_in *pAddr, const char *pchBuffer, int cchBuffer);
62    
63    
64     //-------------------------------------------------------------------------
65     // Threaded socket agent struct helpers.
66    
67     typedef struct _lscp_socket_agent_t {
68    
69     lscp_socket_t sock;
70     struct sockaddr_in addr;
71     lscp_thread_t *pThread;
72     int iState;
73    
74     } lscp_socket_agent_t;
75    
76     void lscp_socket_agent_init (lscp_socket_agent_t *pAgent, lscp_socket_t sock, struct sockaddr_in *pAddr, int cAddr);
77     lscp_status_t lscp_socket_agent_start (lscp_socket_agent_t *pAgent, lscp_thread_proc_t pfnProc, void *pvData, int iDetach);
78     lscp_status_t lscp_socket_agent_join (lscp_socket_agent_t *pAgent);
79     lscp_status_t lscp_socket_agent_free (lscp_socket_agent_t *pAgent);
80    
81     #if defined(__cplusplus)
82     }
83     #endif
84    
85    
86     #endif // __LSCP_SOCKET_H
87    
88     // end of socket.h

  ViewVC Help
Powered by ViewVC