/// <summary> /// Add a socket to a socket set /// </summary> /// <remarks> /// Add a socket to a socket set that will be watched. /// <p>Binds to C-function call in SDL_net.h: /// <code> /// #define SDLNet_TCP_AddSocket(set, sock) SDLNet_AddSocket(set, (SDLNet_GenericSocket)sock) /// </code> /// </p> /// </remarks> /// <returns> /// the number of sockets used in the set on success. -1 is returned on errors. /// </returns> /// <example> /// <code> /// // add two sockets to a socket set /// //SDLNet_SocketSet set; /// //UDPsocket udpsock; /// //TCPsocket tcpsock; /// int numused; /// /// numused=SDLNet_UDP_AddSocket(set,udpsock); /// if(numused==-1) { /// printf("SDLNet_AddSocket: %s\n", SDLNet_GetError()); /// // perhaps you need to restart the set and make it bigger... /// } /// numused=SDLNet_TCP_AddSocket(set,tcpsock); /// if(numused==-1) { /// printf("SDLNet_AddSocket: %s\n", SDLNet_GetError()); /// // perhaps you need to restart the set and make it bigger... /// } /// </code> /// </example> /// <seealso cref="SDLNet_AllocSocketSet"/> /// <seealso cref="SDLNet_DelSocket"/> /// <seealso cref="SDLNet_CheckSockets"/> /// <seealso cref="SDLNet_SocketSet"/> /// <seealso cref="UDPsocket"/> /// <seealso cref="TCPsocket"/> /// <param name="set"> /// The socket set to add this socket to /// </param> /// <param name="sock"> /// The socket to add to the socket set /// </param> public static int SDLNet_TCP_AddSocket(SDLNet_SocketSet set, IntPtr sock) { SdlNet.SDLNet_GenericSocket genericSocket = (SdlNet.SDLNet_GenericSocket)Marshal.PtrToStructure(sock, typeof(SdlNet.SDLNet_GenericSocket)); return SdlNet.SDLNet_AddSocket(set, genericSocket); }
public static extern void SDLNet_FreeSocketSet(SDLNet_SocketSet set);
public static extern void SDLNet_DelSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock);
public static extern int SDLNet_CheckSockets(SDLNet_SocketSet set, int timeout);
public static extern int SDLNet_AddSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock);
/// <summary> /// Remove a socket from a socket set /// </summary> /// <remarks> /// Free the socket set from memory. /// Do not reference the set after this call, /// except to allocate a new one. /// <p>Binds to C-function call in SDL_net.h: /// <code> /// #define SDLNet_UDP_DelSocket(set, sock) SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock) /// </code> /// </p> /// </remarks> /// <returns> /// the number of sockets used in the set on success. -1 is returned on errors. /// </returns> /// <example> /// <code> /// // remove two sockets from a socket set /// //SDLNet_SocketSet set; /// //UDPsocket udpsock; /// //TCPsocket tcpsock; /// int numused; /// /// numused=SDLNet_UDP_DelSocket(set,udpsock); /// if(numused==-1) { /// printf("SDLNet_DelSocket: %s\n", SDLNet_GetError()); /// // perhaps the socket is not in the set /// } /// numused=SDLNet_TCP_DelSocket(set,tcpsock); /// if(numused==-1) { /// printf("SDLNet_DelSocket: %s\n", SDLNet_GetError()); /// // perhaps the socket is not in the set /// } /// </code> /// </example> /// <seealso cref="SDLNet_AddSocket"/> /// <seealso cref="SDLNet_FreeSocketSet"/> /// <seealso cref="SDLNet_SocketSet"/> /// <seealso cref="UDPsocket"/> /// <seealso cref="TCPsocket"/> /// <param name="set"> /// The socket set to remove this socket from /// </param> /// <param name="sock"> /// the socket to remove from the socket set /// </param> public static void SDLNet_UDP_DelSocket(SDLNet_SocketSet set, IntPtr sock) { SdlNet.SDLNet_GenericSocket genericSocket = (SdlNet.SDLNet_GenericSocket)Marshal.PtrToStructure(sock, typeof(SdlNet.SDLNet_GenericSocket)); SdlNet.SDLNet_DelSocket(set, genericSocket); }