Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub CmdClear_Click()
- TxtRcv.Text = ""
- End Sub
- Private Sub CmdSend_Click()
- WinSock.RemoteHost = "255.255.255.255" 'ip do equipamento'
- WinSock.SendData TxtSend.Text
- End Sub
- Private Sub WinSock_DataArrival(ByVal bytesTotal As Long)
- WinSock.GetData s$
- TxtRcv.Text = TxtRcv.Text + s$ + Chr$(13) + Chr$(10)
- End Sub
- private static void Main(string[] args)
- {
- var host = IPAddress.Parse("192.168.25.200");
- var hostep = new IPEndPoint(host, 3000);
- var sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Unspecified);
- try
- {
- sock.Connect(hostep);
- }
- catch (SocketException e)
- {
- Console.WriteLine("Problem connecting to host");
- Console.WriteLine(e.ToString());
- sock.Close();
- return;
- }
- try
- {
- sock.SendTo(Encoding.ASCII.GetBytes("V"), hostep);
- }
- catch (SocketException e)
- {
- Console.WriteLine("Problem sending data");
- Console.WriteLine(e.ToString());
- sock.Close();
- return;
- }
- var receivingUdpClient = new UdpClient(3000);
- try
- {
- var receiveBytes = receivingUdpClient.Receive(ref hostep);
- var returnData = Encoding.ASCII.GetString(receiveBytes);
- Console.WriteLine("Mensagem recebida " + returnData);
- }
- catch (Exception e)
- {
- Console.WriteLine(e.ToString());
- }
- sock.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement