using java connect it, error : 试图超越文件尾对文件进行读写.Server is the MSDN sample CHATSRVRhelp!!! help!!!!谁能用 WinSocket api 写一个程序
发送字符到 CHATSRVR
在CHATSRVR 上显示出来就可以
问题的难度就因为CHATSRVR 不是使用的SocketApiCHATSRVR 就是MSDN 上的一个例子 ,在MSDN光盘上就有, 或者到MSDN下载.使用sniffer 监听 CHATTER/CHATSRVR 的数据收发, 然后模仿
我实验过,没成功. 或许我使用的 sniffer 程序有问题,或许我不会使用sniffer.
我用的sniffer是Visual Sniffer Thanks!
发送字符到 CHATSRVR
在CHATSRVR 上显示出来就可以
问题的难度就因为CHATSRVR 不是使用的SocketApiCHATSRVR 就是MSDN 上的一个例子 ,在MSDN光盘上就有, 或者到MSDN下载.使用sniffer 监听 CHATTER/CHATSRVR 的数据收发, 然后模仿
我实验过,没成功. 或许我使用的 sniffer 程序有问题,或许我不会使用sniffer.
我用的sniffer是Visual Sniffer Thanks!
解决方案 »
- 求助:关于取小数位的问题
- 菜鸟初来,散100分,同时祝新年快乐
- CListContrl改变不了颜色啦,快来帮帮我,谢谢,附上全部源代码
- 请问chi文件是用什么工具生成?
- 谁能帮我啊!!!!我真的没有办法了!inetinfo.exe一启动就占用了100%的CPU资源。100分!
- 请问各路高手,关于在网页上自动下载控件的问题(高分啊。:))
- 弹出窗口父窗口是桌面时,关闭很 闪烁主程序~
- 绘制描述事件先后顺序的前驱图
- 求助,MFC 使用picture control显示图像出现问题。
- 为什么static text控件中得字体会不同?
- 紧急求助,关于一个应用程序里创建两个线程的问题!!!
- 请教:知道线程的ID,怎样才知道这个线程属于哪一个进程?
{
WSADATA wsaData;
SOCKET ListeningSocket;
SOCKET NewConnection;
SOCKADDR_IN ServerAddr;
SOCKADDR_IN ClientAddr;
int Port = 5150;
// Initialize Winsock version 2.2 WSAStartup(MAKEWORD(2,2), &wsaData);
// Create a new socket to listen for client connections.
ListeningSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
// Set up a SOCKADDR_IN structure that will tell bind that we
// want to listen for connections on all interfaces using port
// 5150. Notice how we convert the Port variable from host byte
// order to network byte order.
ServerAddr.sin_family = AF_INET;
ServerAddr.sin_port = htons(Port);
ServerAddr.sin_addr.s_addr = htonl(INADDR_ANY);
// Associate the address information with the socket using bind.
bind(ListeningSocket, (SOCKADDR *)&ServerAddr,
sizeof(ServerAddr)); // Listen for client connections. We used a backlog of 5, which
// is normal for many applications. listen(ListeningSocket, 5); // Accept a new connection when one arrives. NewConnection = accept(ListeningSocket, (SOCKADDR *)
&ClientAddr,&ClientAddrLen)); // At this point you can do two things with these sockets. Wait
// for more connections by calling accept again on ListeningSocket
// and start sending or receiving data on NewConnection. We will
// describe how to send and receive data later in the chapter. // When you are finished sending and receiving data on the
// NewConnection socket and are finished accepting new connections
// on ListeningSocket, you should close the sockets using the
// closesocket API. We will describe socket closure later in the
// chapter. closesocket(NewConnection);
closesocket(ListeningSocket); // When your application is finished handling the connections,
// call WSACleanup. WSACleanup();
}
上面一大堆,修改服务器的端口号和ip地址就可以直接使用了
自己去下载,现成的程序