When I try to connect to my computer using tcp/ip it says my computer activly rejected the connetion. Why does that hapen?
When I try to connect to my computer using tcp/ip it says my computer activly rejected the connetion. Why does that hapen?
Check your firewalls - McAfee, Norton, Windows Firewall too.
Hmm ok I did, I even turned them all off for a tiby bit to check, still didn't work. I can play games online and do everythin else with tcp/ip but not my own program.
I can't connect to any perosns comupter, only web sites and other stuff like that. WHy can't I?
Nobody can help you if you don't post code.
To code is divine
sorry I thought I did...
first I int some variables
then I connectCode:IPAddress IP; TcpClient tcp; NetworkStream net; StreamReader read; StreamWriter write; bool connected = false;
if the connection works, which I get the error while connecting I can ping with this codeCode:IP = IPAddress.Parse(textBox_ip.Text); tcp = new TcpClient(); tcp.Connect(IP, int.Parse(textBox_Port.Text)); if (tcp.Connected) { textBox_Conver.AppendText("Connected\r\n"); connected = true; } net = tcp.GetStream(); read = new StreamReader(net); write = new StreamWriter(net);
That should be enough, and it does work for websites, but not for ragular computers.Code:if (connected == true) { textBox_Conver.AppendText("Pinging...\r\n"); Ping ping = new Ping(); PingReply reply = ping.Send(IP); long time = reply.RoundTripTime; textBox_Conver.AppendText("Ping: " + time.ToString() + "\r\n"); textBox_Conver.AppendText("Ready \r\n"); }
Are you trying to talk to computers on your home network which are connected with a router? It probably has an option whether to let them talk to each other or just to talk to the primary (internet) connection. And your testing probably went to local for the stuff that failed and the internet for http stuff. If you are using a hub its hard wired, but they probably can talk to each other, if not you can't fix it.
hrmm so I am on dial up, but still I can not talk to my own computer on my own computer? I can do this with other programs and Game Maker.
I assume the problem is because nothing is listening for your connection. When you start up a game that employs some networking, it will be listening for connections, and connect to a server that is also listening for connections. Do you have any program running on the target computer that is awaiting your connection?
hrmmm that brings a whole new concept. Ok I see what I need to do, my program is sorta blunt. And I guess web sites are always listening for connections I am guessing. Ok I see what I am doing wrong.
Ping's got nothing to do with programs listening for connections. There is no point creating a Tcp connection if you're just using ping. "Ping" is not a software service and doesn't listen on a particular port (as the TCP connection does). It uses ICMP packets and replies are handled at the OS level.
You've created the streams to read and write from the socket, but you're not actually writing any data.
Heres a test - try connecting to www.google.com on port 80 (HTTP standard port). Use the stream writer to write "GET / HTTP/1.0\r\n\r\n" (a standard "show me the page baby!" HTTP request). Then use the reader to get the response.
As Sean pointed out, the problem is probably that the computers aren't listening on the ports you try and connect to - use TcpServer (or TcpHost?) to create a server to accept incoming connections in one program, and TcpClient in another to connect to it.
hmm so using the stream I really can send data just like a packet? And I read up on ping last night and figured out it has notin to do with connections.
And I will try that test after I get my Counter Strike Source tower's physics correct.