473,770 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem connecting Server/Client, TCP

3 New Member
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 1960
RedSon
5,000 Recognized Expert Expert
...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
MaxPersson
3 New Member
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 Recognized Expert Contributor
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 Recognized Expert Expert
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 Recognized Expert Contributor
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 Recognized Expert Expert
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:50 01 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
2547
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 server and send and recieve messages to/from the server but when I send a message from one client I can't get the message to appear in the second client. I think it's something to do with threads but I don't know what! I've been looking at the...
1
3795
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 pending connections every 500ms. I also have a vb6 application that uses the WinSock control at the other end of the communication tunel. I have to work with vb6 here because it uses less memory than .NET.
3
5134
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. When i try to connect to a server that doesnt exist it raises a "Connection forcibly rejected by the resmote host" SocketException.
0
1919
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 to it made in vb6. Some of the code in the server are based on the basic samples that i get from other authors. To give you an idea, the server uses sockets,
1
2089
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 UI for interacting with the instruments. Readings from the instruments are periodically sent to the clients, and clients will send commands to the server based on user input. In normal usage there will be around 6 clients connected, with a...
0
3922
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 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any one tell me how to set TCP\IP connection protocol on server for particular instance. Becuase I think
5
24017
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 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any one tell me how to set TCP\IP
0
2867
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 HotSpot(TM) Client VM User home directory = C:\Documents and Settings\noa ---------------------------------------------------- c: clear console window
9
4304
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 some packets in response to the programs first message, but when I receive a response back, it's the last packet I sent. After that packet, I receive the packet I really wanted. This only happens when I connect with local host. I tried...
10
15957
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 60003/tcp
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.