Question Weird UPD Problem

avile22

Member
Joined
Oct 12, 2008
Messages
8
Programming Experience
5-10
Im using System.Net.Sockets.Socket to communicate between 2 computers on my network using UDP protocol to send and receive Players Positions in the 3D World of a multiplayer game I am writing.

THE WIERD PROBLEM:

1) When I run the program from within VB.net 2005 I get no errors but cannot make the connection or transfer data when sending my data over the network.

2) When I run the same program from the built .exe in the BIN folder I have no problems and the connection is made and data is transmitted.

This is driving me nuts! Anyone please help!
 
Firewall? When debugging app.vshost.exe must be allowed through fw, when running app.exe directly this must be allowed.
 
JohnH

Thanks for your reply. I thought your idea would definetly cure this issue and I even closed out my firewall programs and played with security setting for both my app and VB.net.

Still I get nothing from my recieving client! My send app gives no errors and acts as if its sending.

I just know that my code is working fine because I can run the exe and it works fine. But just won't run in VB.net environment.

UDP Send.vshost.exe and Receive.vshost.exe are both in the BINS directory where the built .EXE is.
 
OK

I narrowed it down to my receiving client app.

I ran an instance of my Sending app from VB.net and an instance of the same app from the .exe (in the BIN folder.)

I ran an instance of my receiving app from the .exe (in the BIN folder) and sent data from both instances of the sending app mentioned above and all worked well.

Now when I close the receiving app from the .exe (in the BIN folder) and open the same receiving project in VB.net THE PROBLEM IS BACK! No data is received!
 
IN CASE ANYBODY HAS THE SAME PROBLEM

OK! I finally answered my own problem! After a week of mind boggling debugging I found that you can not pass data from one thread to a windows form object such as a textbox's text field without doing some comprehense coding or simply using;

System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = False

before any Try method as in:




System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = False

Try
GLOIP = IPAddress.Parse(txtIP.Text)
GLOINTPORT = txtPort.Text
udpClient.Connect(GLOIP, GLOINTPORT)
bytCommand = Encoding.ASCII.GetBytes(txtMessage.Text)
End Try


This fixed my problem!
 
Interesting catch, but setting CheckForIllegalCrossThreadCalls False doesn't solve your problem, it simply ignores it. Use Control.Invoke or Control.BeginInvoke when you need to access UI thread from other threads.
 
Back
Top