1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %% Name: dgramsocket.tex
3 %% Purpose: wxSocket docs
4 %% Author: Angel Vidal Veiga (kry@amule.org)
8 %% Copyright: (c) wxWidgets team
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 % ---------------------------------------------------------------------------
13 % CLASS wxDatagramSocket
14 % ---------------------------------------------------------------------------
16 \section{\class{wxDatagramSocket
}}\label{wxdatagramsocket
}
18 \wxheading{Derived from
}
20 \helpref{wxSocketBase
}{wxsocketbase
}
22 \wxheading{Include files
}
26 \latexignore{\rtfignore{\wxheading{Members
}}}
28 % ---------------------------------------------------------------------------
30 % ---------------------------------------------------------------------------
34 \membersection{wxDatagramSocket::wxDatagramSocket
}\label{wxdatagramsocketctor
}
36 \func{}{wxDatagramSocket
}{\param{wxSocketFlags
}{ flags = wxSOCKET
\_NONE}}
40 \wxheading{Parameters
}
42 \docparam{flags
}{Socket flags (See
\helpref{wxSocketBase::SetFlags
}{wxsocketbasesetflags
})
}
47 \membersection{wxDatagramSocket::
\destruct{wxDatagramSocket
}}\label{wxdatagramsocketdtor
}
49 \func{}{\destruct{wxDatagramSocket
}}{\void}
51 Destructor. Please see
\helpref{wxSocketBase::Destroy
}{wxsocketbasedestroy
}.
56 \membersection{wxDatagramSocket::Connect
}\label{wxdatagramsocketconnect
}
58 \func{bool
}{Connect
}{\param{wxSockAddress\&
}{ address
}}
60 Connects to another peer using the specified address.
62 Connecting in an UDP socket like the one wxDatagramSocket creates is different
63 from TCP socket's idea of connect. Give then fact that UDP is a connectionless
64 protocol, the meaning of wxDatagramSocket::Connect is that of the unix connect()
65 call when used with with UDP sockets. This means the socket send/receive will be bind
66 to the wxSockAddress specified, and no datagrams will be send or received from other
69 The Connect() call can be isued several times with no drawbacks, to change the destination
72 {\bf Warning:
} When a Connect() has been called on a socket, calling
\helpref{ReceiveFrom
}{wxdatagramsocketreceivefrom
} or
\helpref{SendTo
}{wxdatagramsocketsendto
} with a different wxSockAddress will result in an assertion on debug mode and
73 no data being sent/received on both debug and release modes. Use
74 \helpref{Read()
}{wxsocketbaseread
} and
\helpref{Write()
}{wxsocketbasewrite
}
75 after calling Connect() to make sure you're reading from/writing to the proper destination.
77 \wxheading{Parameters
}
79 \docparam{address
}{Address of the destination peer.
}
81 \wxheading{Return value
}
83 Returns true if the connect() call is successful and socket is correctly
84 attached to the destination address.
88 \helpref{wxDatagramSocket::Disconnect
}{wxdatagramsocketdisconnect
},
90 \newsince{2.7.0} { There was no way to Connect() an wxDatagramSocket before
}.
95 \membersection{wxDatagramSocket::Disconnect
}\label{wxdatagramsocketdisconnect
}
97 \func{bool
}{Disconnect
}{}
99 Removes previously bind to an specific destination address set by a
100 \helpref{Connect()
}{wxdatagramsocketconnect
} call.
102 The Disconnect() call can be isued several times with no drawbacks. No error is set
103 if the socket was not connected.
106 \wxheading{Parameters
}
109 \wxheading{Return value
}
111 Returns true if the socket was sucessfully deatached from the destination address.
115 \helpref{wxDatagramSocket::Connect
}{wxdatagramsocketconnect
},
117 \newsince{2.7.0} { There was no way to Connect() an wxDatagramSocket before.
}
122 \membersection{wxDatagramSocket::ReceiveFrom
}\label{wxdatagramsocketreceivefrom
}
124 \func{wxDatagramSocket\&
}{ReceiveFrom
}{\param{wxSockAddress\&
}{ address
},
\param{void *
}{ buffer
},
\param{wxUint32
}{ nbytes
}}
126 This function reads a buffer of
{\it nbytes
} bytes from the socket.
128 Use
\helpref{LastCount
}{wxsocketbaselastcount
} to verify the number of bytes actually read.
130 Use
\helpref{Error
}{wxsocketbaseerror
} to determine if the operation succeeded.
132 \wxheading{Parameters
}
134 \docparam{address
}{Any address - will be overwritten with the address of the peer that sent that data.
}
136 \docparam{buffer
}{Buffer where to put read data.
}
138 \docparam{nbytes
}{Number of bytes.
}
140 \wxheading{Return value
}
142 Returns a reference to the current object, and the address of the peer that sent the data on address param.
144 \wxheading{Remark/Warning
}
146 If a
\helpref{Connect()
}{wxdatagramsocketconnect
} call is issued before ReceiveFrom is called,
147 the address sent on this call MUST match the one ussed on the Connect() call, or this call will assert. It's usually a good idea to use
\helpref{wxSocketBase::Read
}{wxsocketbaseread
} in this case.
151 \helpref{wxSocketBase::Error
}{wxsocketbaseerror
},
152 \helpref{wxSocketBase::LastError
}{wxsocketbaselasterror
},
153 \helpref{wxSocketBase::LastCount
}{wxsocketbaselastcount
},
154 \helpref{wxSocketBase::SetFlags
}{wxsocketbasesetflags
},
155 \helpref{Connect()
}{wxdatagramsocketconnect
}
160 \membersection{wxDatagramSocket::SendTo
}\label{wxdatagramsocketsendto
}
162 \func{wxDatagramSocket\&
}{SendTo
}{\param{const wxSockAddress\&
}{ address
},
\param{const void *
}{ buffer
},
\param{wxUint32
}{ nbytes
}}
164 This function writes a buffer of
{\it nbytes
} bytes to the socket.
166 Use
\helpref{LastCount
}{wxsocketbaselastcount
} to verify the number of bytes actually wrote.
168 Use
\helpref{Error
}{wxsocketbaseerror
} to determine if the operation succeeded.
170 \wxheading{Parameters
}
172 \docparam{address
}{The address of the destination peer for this data.
}
174 \docparam{buffer
}{Buffer where read data is.
}
176 \docparam{nbytes
}{Number of bytes.
}
178 \wxheading{Return value
}
180 Returns a reference to the current object.
182 \wxheading{Remark/Warning
}
184 If a
\helpref{Connect()
}{wxdatagramsocketconnect
} call is issued before SendTo is called,
185 the address sent on this call MUST match the one ussed on the Connect() call, or this call will assert. It's usually a good idea to use
\helpref{wxSocketBase::Write
}{wxsocketbasewrite
} in this case.
189 \helpref{wxSocketBase::Error
}{wxsocketbaseerror
},
190 \helpref{wxSocketBase::LastError
}{wxsocketbaselasterror
},
191 \helpref{wxSocketBase::LastCount
}{wxsocketbaselastcount
},
192 \helpref{wxSocketBase::SetFlags
}{wxsocketbasesetflags
}
193 \helpref{Connect()
}{wxdatagramsocketconnect
}