#include <ServerSocket.hpp>
Inheritance diagram for ServerSocket::

Public Methods | |
| int | bind (struct sockaddr *sa=NULL) |
| int | listen (int bklog=4) |
| Socket * | accept () throw (int) |
| void | close () |
| void | shutdownInput () |
| void | shutdownOutput () |
| void | shutdown (int how=2) |
| sockaddr * | getSockAddr () |
| int | getSocket () |
| int | getDomain () |
| int | getType () |
| int | getProtocol () |
| int | setSockOpt (int level, int optname, void *optval, socklen_t optlen) |
| void * | getSockOpt (int level, int optname, void *optval, socklen_t *optlen) |
Protected Methods | |
| ServerSocket (sockaddr *sa=NULL, int domain=PF_INET, int type=SOCK_STREAM, int protocol=0) throw (int) | |
| ServerSocket (ServerSocket &original) throw (int) | |
Protected Attributes | |
| int | s_domain |
| int | s_type |
| int | s_protocol |
| sockaddr * | lsa |
| sockaddr | local_sa |
| int | sck |
| int | backlog |
|
||||||||||||||||||||
|
Definition at line 15 of file ServerSocket.cpp. 00016 {
00017 s_domain = domain;
00018 s_type = type;
00019 s_protocol = protocol;
00020 lsa = NULL;
00021
00022 sck = socket(domain,type,protocol);
00023
00024 if( sck == -1 )
00025 {
00026 throw errno;
00027 }
00028 else {
00029 if(sa != NULL) {
00030 local_sa.sa_family = sa->sa_family;
00031 for (int i = 0;i<14;i++) local_sa.sa_data[i] = sa->sa_data[i];
00032 lsa = &local_sa;
00033 }
00034 else {
00035 /*
00036 local_sa.sa_family = AF_INET;
00037 memset(&(local_sa.sa_data), '\0', 14);
00038 ((struct sockaddr_in*)local_sa).sin_port = htons(0);
00039 ((struct sockaddr_in)local_Sa).sin_addr.s_addr = htonl(INADDR_ANY);
00040 lsa = &local_sa;
00041 */
00042 }
00043 }
00044 }
|
|
|
Definition at line 46 of file ServerSocket.cpp. 00047 {
00048 struct sockaddr* tmp;
00049
00050 s_domain = original.getDomain();
00051 s_type = original.getType();
00052 s_protocol = original.getProtocol();
00053
00054 sck = socket(s_domain,s_type,s_protocol);
00055 if(sck == -1)
00056 {
00057 throw errno;
00058 }
00059 else
00060 {
00061 tmp = original.getSockAddr();
00062 local_sa.sa_family = tmp->sa_family;
00063 for (int i = 0;i<14;i++) local_sa.sa_data[i] = tmp->sa_data[i];
00064 lsa = &local_sa;
00065 }
00066 }
|
|
|
Definition at line 98 of file ServerSocket.cpp. Referenced by main().
00099 {
00100 int i;
00101 struct sockaddr remote_sa;
00102 struct sockaddr *rsa = &remote_sa;
00103
00104 Socket *ret;
00105 socklen_t sorsa = sizeof(struct sockaddr);
00106
00107 i = ::accept(sck, rsa, &sorsa);
00108
00109 if (i == -1) {
00110 throw(errno);
00111 }
00112 else {
00113 ret = new Socket(i,s_domain, s_type, s_protocol);
00114 return ret;
00115 }
00116 }
|
|
|
Definition at line 72 of file ServerSocket.cpp. Referenced by TcpServerSocket::TcpServerSocket().
|
|
|
Definition at line 118 of file ServerSocket.cpp. 00119 {
00120 ::close(sck);
00121 }
|
|
|
Definition at line 150 of file ServerSocket.cpp. 00151 {
00152 return s_domain;
00153 }
|
|
|
Definition at line 160 of file ServerSocket.cpp. 00161 {
00162 return s_protocol;
00163 }
|
|
|
Definition at line 138 of file ServerSocket.cpp. 00139 {
00140 int size = sizeof(struct sockaddr);
00141 getsockname(sck, lsa, (socklen_t *) &size);
00142 return lsa;
00143 }
|
|
||||||||||||||||||||
|
Definition at line 173 of file ServerSocket.cpp. 00174 {
00175 int ret;
00176 ret = getsockopt(sck, level, optname, optval, optlen);
00177 if (ret != -1)
00178 {
00179 return optval;
00180 }
00181 else
00182 {
00183 return NULL;
00184 }
00185 }
|
|
|
Definition at line 145 of file ServerSocket.cpp. 00146 {
00147 return sck;
00148 }
|
|
|
Definition at line 155 of file ServerSocket.cpp. 00156 {
00157 return s_type;
00158 }
|
|
|
Definition at line 88 of file ServerSocket.cpp. |
|
||||||||||||||||||||
|
Definition at line 165 of file ServerSocket.cpp. Referenced by TcpServerSocket::setSoTimeout().
00166 {
00167 int ret;
00168 ret = setsockopt(sck, level, optname, optval, optlen);
00169 return ret;
00170 }
|
|
|
Definition at line 123 of file ServerSocket.cpp. 00124 {
00125 ::shutdown(sck, how);
00126 }
|
|
|
Definition at line 128 of file ServerSocket.cpp. 00129 {
00130 ::shutdown(sck, 0);
00131 }
|
|
|
Definition at line 133 of file ServerSocket.cpp. 00134 {
00135 ::shutdown(sck, 1);
00136 }
|
|
|
Definition at line 50 of file ServerSocket.hpp. |
|
|
Definition at line 48 of file ServerSocket.hpp. |
|
|
Definition at line 47 of file ServerSocket.hpp. |
|
|
Definition at line 44 of file ServerSocket.hpp. |
|
|
Definition at line 46 of file ServerSocket.hpp. |
|
|
Definition at line 45 of file ServerSocket.hpp. |
|
|
Definition at line 49 of file ServerSocket.hpp. |
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001