c 下的Socket網路通訊 類庫

2021-04-13 06:31:51 字數 898 閱讀 9215

宣告:單執行緒 (多執行緒 尚待完善)

環境:vs.net2005;

介面 : dos;

語言 :c#

using system;

using system.collections;

using system.collections.generic;

using system.text;

using system.net;

using system.net.sockets;

using system.threading;

namespace server

public void socketbind()

public void socketlisten()

public socket acceptmethod()

public void sendreceivetest(socket server)//不能用static

",str1);}

}catch (socketexception e)

error code:.", e.message, e.errorcode); }

} public void socketclose()}

} namespace client

public void socketconn()

public void receivemsg()

", strrec);

}         

catch(exception ex)

}       

public void socketsend()//public?

catch

}public void socketclose()

catch}}

}  

Socket網路通訊

服務端的程式如下 1.建立乙個伺服器端socket,即serversocket,指定繫結的埠,並監聽此埠8888 serversocket serversocket new serversocket 8888 socket socket null 記錄客戶端的數量 int count 0 syste...

socket網路通訊

read write recv send readv writev recvmsg sendmsg recvfrom sendto include ssize t read int fd,void buf,size t count ssize t write int fd,const void bu...

windows下socket 網路通訊程式設計二

該版本在版本一基礎上增加了伺服器反饋功能,實現了伺服器接收成功後給客戶端傳送接收成功訊息。在vc6.0下即可執行成功 windows下socket伺服器程式 include include pragma comment lib,ws2 32.lib int main void wsacleanup ...