(转)WinForm实现在服务器端创建文件夹
来源:互联网 发布:最好的数据统计软件 编辑:程序博客网 时间:2024/05/16 13:00
//client端usingSystem;usingSystem.Text;usingSystem.IO;usingSystem.Net;usingSystem.Net.Sockets;namespacesocketsample{ classClass1 { staticvoidMain() { try { intport=2000; stringhost="127.0.0.1"; IPAddressip=IPAddress.Parse(host); IPEndPointipe=newIPEndPoint(ip,port);//把ip和端口转化为IPEndPoint实例 Socketc=newSocket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);//创建一个Socket Console.WriteLine("Conneting..."); c.Connect(ipe);//连接到服务器 stringsendStr="hello!Thisisasockettest"; byte[]bs=Encoding.ASCII.GetBytes(sendStr); Console.WriteLine("SendMessage"); c.Send(bs,bs.Length,0);//发送测试信息 stringrecvStr=""; byte[]recvBytes=newbyte[1024]; intbytes; bytes=c.Receive(recvBytes,recvBytes.Length,0);//从服务器端接受返回信息 recvStr+=Encoding.ASCII.GetString(recvBytes,0,bytes); Console.WriteLine("ClientGetMessage:{0}",recvStr);//显示服务器返回信息 c.Close(); } catch(ArgumentNullExceptione) { Console.WriteLine("ArgumentNullException:{0}",e); } catch(SocketExceptione) { Console.WriteLine("SocketException:{0}",e); } Console.WriteLine("PressEntertoExit"); Console.ReadLine(); } }}//server端usingSystem;usingSystem.Text;usingSystem.IO;usingSystem.Net;usingSystem.Net.Sockets;namespaceProject1{ classClass2 { staticvoidMain() { try { intport=2000; stringhost="127.0.0.1"; IPAddressip=IPAddress.Parse(host); IPEndPointipe=newIPEndPoint(ip,port); Sockets=newSocket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);//创建一个Socket类 s.Bind(ipe);//绑定2000端口 s.Listen(0);//开始监听 Console.WriteLine("Waitforconnect"); Sockettemp=s.Accept();//为新建连接创建新的Socket。 Console.WriteLine("Getaconnect"); stringrecvStr=""; byte[]recvBytes=newbyte[1024]; intbytes; bytes=temp.Receive(recvBytes,recvBytes.Length,0);//从客户端接受信息 recvStr+=Encoding.ASCII.GetString(recvBytes,0,bytes); Console.WriteLine("ServerGetMessage:{0}",recvStr);//把客户端传来的信息显示出来 stringsendStr="Ok!ClientSendMessageSucessful!"; byte[]bs=Encoding.ASCII.GetBytes(sendStr); temp.Send(bs,bs.Length,0);//返回客户端成功信息 temp.Close(); s.Close(); } catch(ArgumentNullExceptione) { Console.WriteLine("ArgumentNullException:{0}",e); } catch(SocketExceptione) { Console.WriteLine("SocketException:{0}",e); } Console.WriteLine("PressEntertoExit"); Console.ReadLine(); } }}
0 0
- (转)WinForm实现在服务器端创建文件夹
- c# winform 服务器端创建 文件夹
- C++实现创建winform
- 在服务器端如何创建目录
- 在vc6中,如何创建“浏览文件夹”对话框(转)
- 在vc中创建目录(文件夹)
- [转]在WinForm中通过HTTP协议向服务器端上传文件
- 在WinForm中通过HTTP协议向服务器端上传文件(转载)
- android读写文件的实现(针对android4.4不能在sdcard根目录下创建文件夹)
- 使用java实现在HDFS中创建文件夹
- 在winform上实现浏览文件夹控件并将值传到后台及浏览文件控件
- java实现创建文件夹
- C#.winform中实现文件夹对话框
- C# winform 实现选择文件夹对话框
- C# winform 实现选择文件夹对话框
- 在服务器端实现定时任务
- 在WinForm中通过HTTP协议向服务器端上传文件
- 在WinForm中通过HTTP协议向服务器端上传文件
- mac 之 iTerm
- 检测TCP网络断开的几种情况
- 简记tp的一个小知识点
- Spring--IoC--基于XML的DI-为应用指定多个配置文件-平等关系
- 获取全局Context
- (转)WinForm实现在服务器端创建文件夹
- 怎么查询馋乐比的生产日期?
- php+redis实现多台服务器内网存储session并读取
- 字符串的全排列
- springcloud 中使用eureka/ribbon/Hystrix负载均衡及断路器
- ios 截取view上内容 返回image 保证清晰度
- hadoop 2.8 简单数字排序
- static--修饰(局部变量、全局变量、函数)
- ajax 分页完全代码整理