/// <summary> /// Close the current socket the safe way. /// </summary> public static void CloseSocket() { if (GAME_SOCKET == null) { return; } GAME_SOCKET.Close(); GAME_SOCKET = null; }
/// <returns></returns> /// /// <summary> /// Create the socket and connect to the host and /// port provided. /// </summary> /// <param name="hostname"> host name </param> /// <param name="port"> port number </param> /// <param name="handler"></param> /// <returns> Sucess or vice versa. </returns> public static bool CreateNetwork(string hostname, int port, JCS_ClientHandler handler) { if (GAME_SOCKET != null) { return(false); } if (instance.PROTOCAL_TYPE == JCS_ProtocalType.TCP) { GAME_SOCKET = new JCS_TCPGameSocket(handler); GAME_SOCKET.Connect(hostname, port); } else if (instance.PROTOCAL_TYPE == JCS_ProtocalType.UDP) { GAME_SOCKET = new JCS_UDPGameSocket(handler); GAME_SOCKET.Connect(hostname, port); } return(true); }