public User(IPAddress userAddress, String username) { this.userAddress = userAddress; this.username = username; this.sequence = new SequenceID(); this.chatWindow = null; receivedMessages.Changed += new ChangedEventHandler(newMessage); }
//IPEndPoint bCastEP; public void initializeSockets() { // Initialize socket for Broadcast sending bCastSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); bCastSocket.EnableBroadcast = true; IPAddress broadcast = IPAddress.Broadcast; bCastEP = new IPEndPoint(broadcast, bCastPort); // Initialize socket for receiving packets clientReceive = new UdpClient(bCastPort); rcvEP = new IPEndPoint(IPAddress.Any, bCastPort); bCastSeq = new SequenceID(); }
public void initializeSockets() { // Initialize socket for Broadcast sending bCastSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); bCastSocket.EnableBroadcast = true; IPAddress broadcast = IPAddress.Broadcast; bCastEP = new IPEndPoint(broadcast, StaticVars.bCastPort); // Initialize socket for receiving Broadcast packets try { bCastReceive = new UdpClient(StaticVars.bCastPort); } catch (SocketException) { MessageBox.Show("Failed to bind Broadcast Port 8888. Please make " + "sure it is not in use.", "Error: Failed to bind port", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } // Initialize a socket for sending/receiving packets try { msgClient = new UdpClient(StaticVars.msgPort); } catch (SocketException) { MessageBox.Show("Failed to bind Message Port Please make sure it " + "is not in use.", "Error: Failed to bind port 9999", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } bCastRCVEP = new IPEndPoint(IPAddress.Any, 0); // Separate endpoint for messages in case of receiving bCast && // msg at the same time msgRCVEP = new IPEndPoint(IPAddress.Any, 0); bCastSeq = new SequenceID(); }