Created
February 24, 2013 16:05
-
-
Save abbas-oveissi/5024344 to your computer and use it in GitHub Desktop.
sample C# code for socket 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IPAddress ip = IPAddress.Parse("192.168.1.2"); | |
IPEndPoint IpPort = new IPEndPoint(ip, Convert.ToInt32("12345")); | |
Socket main_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); | |
main_socket.Bind(IpPort); | |
main_socket.Listen(int.MaxValue); | |
while (true) | |
{ | |
Socket client = main_socket.Accept(); | |
byte[] msg = System.Text.Encoding.UTF8.GetBytes("Hi"); | |
client.Send(msg); | |
client.Close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment