473,238 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,238 software developers and data experts.

Problem connecting Server/Client, TCP

Hi guys! My first post here is ofcourse a little problem of mine! =) ive been looking pretty mutch everywhere, asking my proffesor and such, and we cant figure this out at all. I even analyzed the network trafic with Wireshark to see what was going on. No luck. So now im turning to you hardcore guys here! =)

Well to the problem. Im doing a really, REALLY simple chat client. (intending to control the mouse over ethernet). Where everything stops is when im trying to connect to the server.

On the client machine im running Vista using standard IPv6, and the Server im running XP Pro with IPv6. When launching the code below i can see from the network analyzing that it is actully sending packets and reciving to and from the server machine.

Then it gives me the most odd explenation ever.
"No connection could be made because the target machine activley refused it".

Ive tried to open up the network as mutch as possible to do a trial and error thing, but still no luck.

I dont even need to have my server app up and running. it still gives me the same message.

This is the Client code:

Expand|Select|Wrap|Line Numbers
  1. public void RunClient()
  2. {    
  3. try    
  4. {        
  5. Client = new TcpClient();        
  6. Client.Connect("192.168.1.33", 50000);        
  7. outputStream = Client.GetStream();        
  8. Writer = new BinaryWriter(outputStream);    
  9. }        
  10. catch (Exception e) { MessageBox.Show(e.ToString()); }    }}
  11.  
  12.  
  13. This is the servercode:
  14.  
  15. private void RunServer()
  16. {    
  17. TcpListener listener;        
  18. try    
  19. {        
  20. IPAddress local = IPAddress.Parse("127.0.0.1");        
  21. listener = new TcpListener(local, 50000);                        
  22. listener.Start();        
  23. while (true)        
  24. {            
  25. Connection = listener.AcceptSocket();            MessageBox.Show("Someone got connected."); ...
  26.  
The servercode doesnt even reach the MessageBox.Show code. Seems like it is something external that is keeping the connection away. Anyone have any idea or could kick me in the right direction?

Thanks in advance for occupying your time =)
Jun 21 '07 #1
6 1940
RedSon
5,000 Expert 4TB
...So now im turning to you hardcore guys here at The Code Project
I'm not sure you have the right place. This is TheScripts not The Code Project.

When you step through your code at what point does it break down? Perhaps you do not have any timeouts for your connections so the server never drops the first connection if it does not receive a packet. You should also make sure that your server side is multi threaded so that it can accept more then one connection from a client.

Can you let me know at what point it fails like what line number? And also try to post up your locals. Maybe that will help?
Jun 21 '07 #2
hehe i saw that =) changed it ;)
either way.
im using a threaded server side since i thought it would be some kind of problem with that. but nope, no luck.

Expand|Select|Wrap|Line Numbers
  1.         private Socket Connection;
  2.         private Thread readThread;
  3.  
  4.         private NetworkStream socketStream;
  5.         private BinaryReader Reader;
That is the locals for the server.

But it seems not to be the problem since i can shutdown my server app and still it gives me the same error.

=(

it fails on line 6, clientside
Jun 21 '07 #3
TRScheel
638 Expert 512MB
hehe i saw that =) changed it ;)
either way.
im using a threaded server side since i thought it would be some kind of problem with that. but nope, no luck.

Expand|Select|Wrap|Line Numbers
  1.         private Socket Connection;
  2.         private Thread readThread;
  3.  
  4.         private NetworkStream socketStream;
  5.         private BinaryReader Reader;
That is the locals for the server.

But it seems not to be the problem since i can shutdown my server app and still it gives me the same error.

=(

it fails on line 6, clientside
I believe its your firewall. I had the same issue when coding something similiar.
Jun 21 '07 #4
RedSon
5,000 Expert 4TB
I think you might be using the wrong method call.

http://msdn2.microsoft.com/en-us/lib...52(VS.71).aspx
Jun 21 '07 #5
TRScheel
638 Expert 512MB
I think you might be using the wrong method call.

http://msdn2.microsoft.com/en-us/lib...52(VS.71).aspx

I dunno, I used nearly the same code and it worked for me
Jun 21 '07 #6
Plater
7,872 Expert 4TB
Then it gives me the most odd explenation ever.
"No connection could be made because the target machine activley refused it".
That message usually occurs when the client can FIND the server (ie the server responds with "yeah Iexist") and means you made it through the firewall*. But the port you are connecting on does not have anyone listening on it.
Say I have a server at 192.168.1.45 and my program is listening on port 5000 and nothing else listening.
If I tell my client to connect to 192.168.1.45:5001 and there is no firewall issues it will tell me "connection actively refused" because it could find my server but there was nothing listening on that port.

* Firewalls generally will NOT respond with anything if the port is not opened, thus having the "connection timed out" in an attempt to trick possibly malicious clients from knowing there is a computer there.

NOW THEN, I just double-checked and saw another problem:
Expand|Select|Wrap|Line Numbers
  1. IPAddress local = IPAddress.Parse("127.0.0.1");        
  2. listener = new TcpListener(local, 50000);                        
  3. listener.Start();   
  4.  
This is only listening on localhost's ip (127.0.0.1) which means ANY other address will not connect to it.
You will want to use IPANY (it's a static under like IPAddress I think)
Jun 21 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ali | last post by:
I'm trying to write a really basic chat program that allows 2 client programs to send messages to each other via a server. I've managed to write the code so that both clients can connect to the...
1
by: Dmitry Akselrod | last post by:
Hello everyone, I have a vb.net application that wraps the TCPListener object in a class. The server connects to the local interface and establishes itself on port 9900. It then polls for...
3
by: David | last post by:
Hi, Ive been trying to work this out for the past 2 days now and im not getting anywhere fast. The problem i have is that i am using Asynchronous sockets to create a Socket Client library....
0
by: richard | last post by:
OS: Winxp and Win2003 Visual Basic.NET 2003 MS-SQL Server 2000 hey all I am a newbie in vb.net but i have managed to build a simple chat server in vb.net using socket and a client connecting...
1
by: Thomee Wright | last post by:
I'm having a problem with a pair of applications I'm developing. I have a server application which interacts with several instruments, and a client app which connects to the server and provides a...
0
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
5
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
0
by: NoaGross | last post by:
Hi, I'm relly new in java and I have a problem. I'm using java applet. When using http all ok, but when trying to use https i get: Java Plug-in 1.5.0_10 Using JRE version 1.5.0_10 Java...
9
by: darthghandi | last post by:
I am trying to create a server application using asynchronous sockets. I run into a problem when I try to connect to my server using a non-.net program. I can establish the connection, and send...
10
by: mairhtin o'feannag | last post by:
Hello, I'm having problems connecting to my new v9 db box. The pertinent information is below: DB2_db2inst1 60000/tcp DB2_db2inst1_1 60001/tcp DB2_db2inst1_2 60002/tcp DB2_db2inst1_END...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.