Click here to Skip to main content
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 11-Apr-13 0:13am

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 390
1 Sergey Alexandrovich Kryukov 329
2 BillWoodruff 210
3 Afzaal Ahmad Zeeshan 204
4 CPallini 185
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 11 Apr 2013
Copyright © CodeProject, 1999-2014
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