1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxSocket docs
4 %% Author: Guillermo Rodriguez Garcia <guille@iies.es>
6 %% Created: 14.01.02 (extracted from socket.tex)
8 %% Copyright: (c) wxWidgets team
9 %% License: wxWidgets license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 % ---------------------------------------------------------------------------
13 % CLASS: wxSocketServer
14 % ---------------------------------------------------------------------------
15 \section{\class{wxSocketServer
}}\label{wxsocketserver
}
17 \wxheading{Derived from
}
19 \helpref{wxSocketBase
}{wxsocketbase
}
21 \wxheading{Include files
}
25 % ---------------------------------------------------------------------------
27 % ---------------------------------------------------------------------------
28 \latexignore{\rtfignore{\wxheading{Members
}}}
33 \membersection{wxSocketServer::wxSocketServer
}\label{wxsocketserverctor
}
35 \func{}{wxSocketServer
}{\param{wxSockAddress\&
}{ address
},
\param{wxSocketFlags
}{ flags = wxSOCKET
\_NONE}}
37 Constructs a new server and tries to bind to the specified
{\it address
}.
38 Before trying to accept new connections, test whether it succeeded with
39 \helpref{wxSocketBase::Ok
}{wxsocketbaseok
}.
41 \wxheading{Parameters
}
43 \docparam{address
}{Specifies the local address for the server (e.g. port number).
}
45 \docparam{flags
}{Socket flags (See
\helpref{wxSocketBase::SetFlags
}{wxsocketbasesetflags
})
}
50 \membersection{wxSocketServer::
\destruct{wxSocketServer
}}\label{wxsocketserverdtor
}
52 \func{}{\destruct{wxSocketServer
}}{\void}
54 Destructor (it doesn't close the accepted connections).
59 \membersection{wxSocketServer::Accept
}\label{wxsocketserveraccept
}
61 \func{wxSocketBase *
}{Accept
}{\param{bool
}{ wait = true
}}
63 Accepts an incoming connection request, and creates a new
64 \helpref{wxSocketBase
}{wxsocketbase
} object which represents
65 the server-side of the connection.
67 If
{\it wait
} is true and there are no pending connections to be
68 accepted, it will wait for the next incoming connection to
69 arrive.
{\bf Warning:
} This will block the GUI.
71 If
{\it wait
} is false, it will try to accept a pending connection
72 if there is one, but it will always return immediately without blocking
73 the GUI. If you want to use Accept in this way, you can either check for
74 incoming connections with
\helpref{WaitForAccept
}{wxsocketserverwaitforaccept
}
75 or catch
{\bf wxSOCKET
\_CONNECTION} events, then call Accept once you know
76 that there is an incoming connection waiting to be accepted.
78 \wxheading{Return value
}
80 Returns an opened socket connection, or NULL if an error occurred or
81 if the
{\it wait
} parameter was false and there were no pending
86 \helpref{wxSocketServer::WaitForAccept
}{wxsocketserverwaitforaccept
},
87 \helpref{wxSocketBase::SetNotify
}{wxsocketbasesetnotify
},
88 \helpref{wxSocketBase::Notify
}{wxsocketbasenotify
},
89 \helpref{wxSocketServer::AcceptWith
}{wxsocketserveracceptwith
}
94 \membersection{wxSocketServer::AcceptWith
}\label{wxsocketserveracceptwith
}
96 \func{bool
}{AcceptWith
}{\param{wxSocketBase\&
}{ socket
},
\param{bool
}{ wait = true
}}
98 Accept an incoming connection using the specified socket object.
100 \wxheading{Parameters
}
102 \docparam{socket
}{Socket to be initialized
}
104 \wxheading{Return value
}
106 Returns true on success, or false if an error occurred or if the
107 {\it wait
} parameter was false and there were no pending
110 \helpref{wxSocketServer::WaitForAccept
}{wxsocketserverwaitforaccept
},
111 \helpref{wxSocketBase::SetNotify
}{wxsocketbasesetnotify
},
112 \helpref{wxSocketBase::Notify
}{wxsocketbasenotify
},
113 \helpref{wxSocketServer::Accept
}{wxsocketserveraccept
}
118 \membersection{wxSocketServer::WaitForAccept
}\label{wxsocketserverwaitforaccept
}
120 \func{bool
}{WaitForAccept
}{\param{long
}{ seconds = -
1},
\param{long
}{ millisecond =
0}}
122 This function waits for an incoming connection. Use it if you want to call
123 \helpref{Accept
}{wxsocketserveraccept
} or
\helpref{AcceptWith
}{wxsocketserveracceptwith
}
124 with
{\it wait
} set to false, to detect when an incoming connection is waiting
127 \wxheading{Parameters
}
129 \docparam{seconds
}{Number of seconds to wait.
130 If -
1, it will wait for the default timeout,
131 as set with
\helpref{SetTimeout
}{wxsocketbasesettimeout
}.
}
133 \docparam{millisecond
}{Number of milliseconds to wait.
}
135 \wxheading{Return value
}
137 Returns true if an incoming connection arrived, false if the timeout elapsed.
141 \helpref{wxSocketServer::Accept
}{wxsocketserveraccept
},
142 \helpref{wxSocketServer::AcceptWith
}{wxsocketserveracceptwith
},
143 \helpref{wxSocketBase::InterruptWait
}{wxsocketbaseinterruptwait
}