Click here to Skip to main content
11,579,093 members (74,352 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET udp
Hi people

I know i've posted something similar to this before, but it's a completely different question.

The problem is, that with the following code, port 54545 does not work. The code is intended to send a message via the port variable to the IP address.
I want the code to be able to, for example, send a message to you, the one reading this, if you have the receiver program (which has to be anywhere in the world, providing you have a network connection)

Imports System.Net
Imports System.Net.Sockets
Imports System.Threading
Imports System.Text
Public Class Form1
    Private Const port As Integer = 54545
    Dim RecipientIPAddress As String = Nothing '255.255.255.255 for local network
    Private sendingClient As UdpClient
    Private Sub SendMsgButton_Click() Handles SendMsgButton.Click
        RecipientIPAddress = IPToSendToTextbox.text 'for example, 192.168.1.99
        InitializeSender()
    End Sub
    Private Sub InitializeSender()
        sendingClient = New UdpClient(RecipientIPAddress, port)
        sendingClient.EnableBroadcast = True
    End Sub
    Public toSend As String
    Dim data() As Byte
    Public Shared Sub go()
        form1.data = Encoding.ASCII.GetBytes(form1.toSend)
        form1.sendingClient.Send(form1.data, form1.data.Length)
    End Sub
   end class


Things I know about the problem:

* UDPClient Ports range from 5454[2-5]
* Port 80 doesn't work

Does anyone know a port number that will work for this?

Thanks.
Posted 10-Apr-13 23:13pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Any port number not in use should work, your problem might be a firewall blocking the traffic.
  Permalink  
Comments
Rixterz123 at 11-Apr-13 5:26am
   
Thanks, but i'll wait for some more replies before i look into it.
I have a code that puts my program in the exceptions list in the firewall; if I run this, will it allow the port?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 183
1 Frankie-C 115
2 Afzaal Ahmad Zeeshan 85
3 Richard Deeming 60
4 Suvendu Shekhar Giri 60
0 OriginalGriff 933
1 Sergey Alexandrovich Kryukov 740
2 Abhinav S 573
3 F-ES Sitecore 420
4 Dave Kreskowiak 419


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 11 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100