Program hangs...
-
Hi!! Its good to be back... I'm working on a simple client server program... server waits for connection and client sends request for connection sort of... simple... On the same m/c but when i start my program... it hangs... it displays all msgs and then hangs.. doesnt respond to anything... then i start my client it connects to the server but server aint responding... i'm using windows forms in place of console app as per tutorials... plz help me... should i attach my code here???
-
Hi!! Its good to be back... I'm working on a simple client server program... server waits for connection and client sends request for connection sort of... simple... On the same m/c but when i start my program... it hangs... it displays all msgs and then hangs.. doesnt respond to anything... then i start my client it connects to the server but server aint responding... i'm using windows forms in place of console app as per tutorials... plz help me... should i attach my code here???
-
Hi!! Its good to be back... I'm working on a simple client server program... server waits for connection and client sends request for connection sort of... simple... On the same m/c but when i start my program... it hangs... it displays all msgs and then hangs.. doesnt respond to anything... then i start my client it connects to the server but server aint responding... i'm using windows forms in place of console app as per tutorials... plz help me... should i attach my code here???
check your server call back function is correct or not.., i think that is the problem, that's way you are able the receive the data for very first time of each new client.
Rajesh B --> A Poor Workman Blames His Tools <--
-
Hi!! Its good to be back... I'm working on a simple client server program... server waits for connection and client sends request for connection sort of... simple... On the same m/c but when i start my program... it hangs... it displays all msgs and then hangs.. doesnt respond to anything... then i start my client it connects to the server but server aint responding... i'm using windows forms in place of console app as per tutorials... plz help me... should i attach my code here???
Whats hanging? The server or client application? Are your listeners and tcp stuff in seperate threads or just running on the UI thread? Are you using blocking or not blocking methods? You really need to give us some code to look at here...
-
Hi!! Its good to be back... I'm working on a simple client server program... server waits for connection and client sends request for connection sort of... simple... On the same m/c but when i start my program... it hangs... it displays all msgs and then hangs.. doesnt respond to anything... then i start my client it connects to the server but server aint responding... i'm using windows forms in place of console app as per tutorials... plz help me... should i attach my code here???
you should not execute blocking calls on the main thread; either use asynchronous methods, or better yet apply proper threading. There are some CP articles on threaded client-server systems. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Hi!! Its good to be back... I'm working on a simple client server program... server waits for connection and client sends request for connection sort of... simple... On the same m/c but when i start my program... it hangs... it displays all msgs and then hangs.. doesnt respond to anything... then i start my client it connects to the server but server aint responding... i'm using windows forms in place of console app as per tutorials... plz help me... should i attach my code here???
Is the listener running in its own thread? It should be.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
Hi!! Its good to be back... I'm working on a simple client server program... server waits for connection and client sends request for connection sort of... simple... On the same m/c but when i start my program... it hangs... it displays all msgs and then hangs.. doesnt respond to anything... then i start my client it connects to the server but server aint responding... i'm using windows forms in place of console app as per tutorials... plz help me... should i attach my code here???
This is the complete source code for my server side program... on clicking the button it calls func conn_man.. on clicking it this program hangs... b4 clicking it.. the program is responding n i can move it resize it n stuff.. but after the button is clicked its not responding.. plz.. tell me how to get it working.. on receiving the connection from client it searches for a free port on the server it self.. when found it sends the client the free port to connect to[ function route does it].. master_slave is another form which is called on accepting a connection from client
namespace master
{
public partial class main_form : Form
{
public int port;
public main_form()
{
InitializeComponent();
activity_win.AppendText("Master On...");
}public void conn\_man() { try { //activity\_win.AppendText("In conn\_man..."); IPAddress ipAd = IPAddress.Parse("192.168.1.2"); // use local m/c IP address, and // use the same in the client /\* Initializes the Listener \*/ TcpListener listener = new TcpListener(ipAd, 5000); /\* Start Listeneting at the specified port \*/ listener.Start(); activity\_win.AppendText("\\r\\nThe server is running at port 5000..."); activity\_win.AppendText("\\r\\nThe local End point is :" + listener.LocalEndpoint); activity\_win.AppendText("\\r\\nWaiting for a connection....."); Socket s = listener.AcceptSocket(); activity\_win.AppendText("\\r\\nConnection accepted from " + s.RemoteEndPoint); byte\[\] b = new byte\[100\]; int k = s.Receive(b); activity\_win.AppendText("Recieved..."); activity\_win.AppendText(ASCIIEncoding.ASCII.GetString(b)); if (route(5000) == 0) { activity\_win.AppendText("No port free"); ASCIIEncoding asen = new ASCIIEncoding(); s.Send(asen.GetBytes("Busy")); } else { port = route(5000); new master\_slave(port); ASCIIEncoding asen = new ASCIIEncoding(); s.Send(asen.GetBytes("Port " + port.ToString())); } /\* clean up \*/
-
This is the complete source code for my server side program... on clicking the button it calls func conn_man.. on clicking it this program hangs... b4 clicking it.. the program is responding n i can move it resize it n stuff.. but after the button is clicked its not responding.. plz.. tell me how to get it working.. on receiving the connection from client it searches for a free port on the server it self.. when found it sends the client the free port to connect to[ function route does it].. master_slave is another form which is called on accepting a connection from client
namespace master
{
public partial class main_form : Form
{
public int port;
public main_form()
{
InitializeComponent();
activity_win.AppendText("Master On...");
}public void conn\_man() { try { //activity\_win.AppendText("In conn\_man..."); IPAddress ipAd = IPAddress.Parse("192.168.1.2"); // use local m/c IP address, and // use the same in the client /\* Initializes the Listener \*/ TcpListener listener = new TcpListener(ipAd, 5000); /\* Start Listeneting at the specified port \*/ listener.Start(); activity\_win.AppendText("\\r\\nThe server is running at port 5000..."); activity\_win.AppendText("\\r\\nThe local End point is :" + listener.LocalEndpoint); activity\_win.AppendText("\\r\\nWaiting for a connection....."); Socket s = listener.AcceptSocket(); activity\_win.AppendText("\\r\\nConnection accepted from " + s.RemoteEndPoint); byte\[\] b = new byte\[100\]; int k = s.Receive(b); activity\_win.AppendText("Recieved..."); activity\_win.AppendText(ASCIIEncoding.ASCII.GetString(b)); if (route(5000) == 0) { activity\_win.AppendText("No port free"); ASCIIEncoding asen = new ASCIIEncoding(); s.Send(asen.GetBytes("Busy")); } else { port = route(5000); new master\_slave(port); ASCIIEncoding asen = new ASCIIEncoding(); s.Send(asen.GetBytes("Port " + port.ToString())); } /\* clean up \*/
-
This is the complete source code for my server side program... on clicking the button it calls func conn_man.. on clicking it this program hangs... b4 clicking it.. the program is responding n i can move it resize it n stuff.. but after the button is clicked its not responding.. plz.. tell me how to get it working.. on receiving the connection from client it searches for a free port on the server it self.. when found it sends the client the free port to connect to[ function route does it].. master_slave is another form which is called on accepting a connection from client
namespace master
{
public partial class main_form : Form
{
public int port;
public main_form()
{
InitializeComponent();
activity_win.AppendText("Master On...");
}public void conn\_man() { try { //activity\_win.AppendText("In conn\_man..."); IPAddress ipAd = IPAddress.Parse("192.168.1.2"); // use local m/c IP address, and // use the same in the client /\* Initializes the Listener \*/ TcpListener listener = new TcpListener(ipAd, 5000); /\* Start Listeneting at the specified port \*/ listener.Start(); activity\_win.AppendText("\\r\\nThe server is running at port 5000..."); activity\_win.AppendText("\\r\\nThe local End point is :" + listener.LocalEndpoint); activity\_win.AppendText("\\r\\nWaiting for a connection....."); Socket s = listener.AcceptSocket(); activity\_win.AppendText("\\r\\nConnection accepted from " + s.RemoteEndPoint); byte\[\] b = new byte\[100\]; int k = s.Receive(b); activity\_win.AppendText("Recieved..."); activity\_win.AppendText(ASCIIEncoding.ASCII.GetString(b)); if (route(5000) == 0) { activity\_win.AppendText("No port free"); ASCIIEncoding asen = new ASCIIEncoding(); s.Send(asen.GetBytes("Busy")); } else { port = route(5000); new master\_slave(port); ASCIIEncoding asen = new ASCIIEncoding(); s.Send(asen.GetBytes("Port " + port.ToString())); } /\* clean up \*/
Why are you doing everything on the primary thread?
I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be
Forgive your enemies - it messes with their heads
-
Why are you doing everything on the primary thread?
I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be
Forgive your enemies - it messes with their heads