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: wxWindows 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
}
27 \helpref{wxNet
}{librarieslist
}
29 % ---------------------------------------------------------------------------
31 % ---------------------------------------------------------------------------
32 \latexignore{\rtfignore{\wxheading{Members
}}}
37 \membersection{wxSocketServer::wxSocketServer
}\label{wxsocketserverctor
}
39 \func{}{wxSocketServer
}{\param{const wxSockAddress\&
}{ address
},
\param{wxSocketFlags
}{ flags = wxSOCKET
\_NONE}}
41 Constructs a new server and tries to bind to the specified
{\it address
}.
42 Before trying to accept new connections, test whether it succeeded with
43 \helpref{wxSocketBase:IsOk
}{wxsocketbaseisok
}.
45 \wxheading{Parameters
}
47 \docparam{address
}{Specifies the local address for the server (e.g. port number).
}
49 \docparam{flags
}{Socket flags (See
\helpref{wxSocketBase::SetFlags
}{wxsocketbasesetflags
})
}
54 \membersection{wxSocketServer::
\destruct{wxSocketServer
}}\label{wxsocketserverdtor
}
56 \func{}{\destruct{wxSocketServer
}}{\void}
58 Destructor (it doesn't close the accepted connections).
63 \membersection{wxSocketServer::Accept
}\label{wxsocketserveraccept
}
65 \func{wxSocketBase *
}{Accept
}{\param{bool
}{ wait = true
}}
67 Accepts an incoming connection request, and creates a new
68 \helpref{wxSocketBase
}{wxsocketbase
} object which represents
69 the server-side of the connection.
71 If
{\it wait
} is true and there are no pending connections to be
72 accepted, it will wait for the next incoming connection to
73 arrive.
{\bf Warning:
} This will block the GUI.
75 If
{\it wait
} is false, it will try to accept a pending connection
76 if there is one, but it will always return immediately without blocking
77 the GUI. If you want to use Accept in this way, you can either check for
78 incoming connections with
\helpref{WaitForAccept
}{wxsocketserverwaitforaccept
}
79 or catch
{\bf wxSOCKET
\_CONNECTION} events, then call Accept once you know
80 that there is an incoming connection waiting to be accepted.
82 \wxheading{Return value
}
84 Returns an opened socket connection, or NULL if an error occurred or
85 if the
{\it wait
} parameter was false and there were no pending
90 \helpref{wxSocketServer::WaitForAccept
}{wxsocketserverwaitforaccept
},
91 \helpref{wxSocketBase::SetNotify
}{wxsocketbasesetnotify
},
92 \helpref{wxSocketBase::Notify
}{wxsocketbasenotify
},
93 \helpref{wxSocketServer::AcceptWith
}{wxsocketserveracceptwith
}
98 \membersection{wxSocketServer::AcceptWith
}\label{wxsocketserveracceptwith
}
100 \func{bool
}{AcceptWith
}{\param{wxSocketBase\&
}{ socket
},
\param{bool
}{ wait = true
}}
102 Accept an incoming connection using the specified socket object.
104 \wxheading{Parameters
}
106 \docparam{socket
}{Socket to be initialized
}
108 \wxheading{Return value
}
110 Returns true on success, or false if an error occurred or if the
111 {\it wait
} parameter was false and there were no pending
114 \helpref{wxSocketServer::WaitForAccept
}{wxsocketserverwaitforaccept
},
115 \helpref{wxSocketBase::SetNotify
}{wxsocketbasesetnotify
},
116 \helpref{wxSocketBase::Notify
}{wxsocketbasenotify
},
117 \helpref{wxSocketServer::Accept
}{wxsocketserveraccept
}
122 \membersection{wxSocketServer::WaitForAccept
}\label{wxsocketserverwaitforaccept
}
124 \func{bool
}{WaitForAccept
}{\param{long
}{ seconds = -
1},
\param{long
}{ millisecond =
0}}
126 This function waits for an incoming connection. Use it if you want to call
127 \helpref{Accept
}{wxsocketserveraccept
} or
\helpref{AcceptWith
}{wxsocketserveracceptwith
}
128 with
{\it wait
} set to false, to detect when an incoming connection is waiting
131 \wxheading{Parameters
}
133 \docparam{seconds
}{Number of seconds to wait.
134 If -
1, it will wait for the default timeout,
135 as set with
\helpref{SetTimeout
}{wxsocketbasesettimeout
}.
}
137 \docparam{millisecond
}{Number of milliseconds to wait.
}
139 \wxheading{Return value
}
141 Returns true if an incoming connection arrived, false if the timeout elapsed.
145 \helpref{wxSocketServer::Accept
}{wxsocketserveraccept
},
146 \helpref{wxSocketServer::AcceptWith
}{wxsocketserveracceptwith
},
147 \helpref{wxSocketBase::InterruptWait
}{wxsocketbaseinterruptwait
}