使用C#编码连接两台计算机 [英] Connecting two computer using C# coding

查看:99
本文介绍了使用C#编码连接两台计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想用c#编码连接2台电脑..
我想要一台电脑作为服务器而另一台作为客户端工作..
我知道一些套接字编程以及..
我读了如何在msdn库中创建一个同步服务器和客户端这里 ..我使用的是那里提到的相同代码..

这两台电脑都有一个实时IP地址,并且不在任何局域网网络上..

我一直在客户端程序中的此异常..

SocketException:System.Net.Sockets.SocketException:连接尝试失败
因为连接方没有正确响应一段时间后,或建立的连接失败,因为连接的主机无法响应122
。162.98.164:11000
 在System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,SocketAddress socketAddress)
 在System.Net.Sock
ets.Socket.Connect(EndPoint remoteEP)
  at consoleclient.Program.Main(String [] args)in C:\ Users\mukul \Desktop\consol
eclient\consoleclient\Program。


i want to connect 2 computers using c# coding..
i want one computer to work as a server and other one as a client..
i know some socket programming as well..
i read how to create a synchronous server and client in msdn library here .. i am using the same code mentioned there..

both the computer have a live ip address and are not on any LAN network..

i keep getting this exception in the client program..

SocketException : System.Net.Sockets.SocketException: A connection attempt failed
because the connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond 122
.162.98.164:11000
  at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
  at System.Net.Sock
ets.Socket.Connect(EndPoint remoteEP)
  at consoleclient.Program.Main(String[] args) in C:\Users\mukul\Desktop\consol
eclient\consoleclient\Program.

推荐答案

您可以在同一台计算机上运行客户端和服务器,并确保客户端可以连接吗?
Can you run both your client and server on the same machine, and make sure that the client can connect?


这篇关于使用C#编码连接两台计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆