关于网友提出的“ 谁能给出这个源代码!SOCKET通讯,服务器及客户端都在自己的机器上”问题疑问,本网通过在网上对“ 谁能给出这个源代码!SOCKET通讯,服务器及客户端都在自己的机器上”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: 谁能给出这个源代码!SOCKET通讯,服务器及客户端都在自己的机器上
描述: 100分
解决方案1: 你自己不会可以问,不要老想着给点分就要源码,这种源码我有很多,但我不给你,如果中国的开发者都像你这样,这个民族就完了.
解决方案2: www.vckbase.com
解决方案3: 一般书上都有例子.copy一个最简单的.由于是用于本地所以把ip改为127.0.0.1就可以了.
如此简单.呵呵.
解决方案4: /*
* For accept, we attempt to create a new socket, set up the link
* with the client, wake up the client, then return the new
* connected fd. We collect the address of the connector in kernel
* space and move it to user at the very end. This is unclean because
* we open the socket then return an error.
*
* 1003.1g adds the ability to recvmsg() to query connection pending
* status to recvmsg. We need to add that support in a way thats
* clean when we restucture accept also.
*/
asmlinkage long sys_accept(int fd, struct sockaddr *upeer_sockaddr, int *upeer_addrlen)
{
struct socket *sock, *newsock;
int err, len;
char address[MAX_SOCK_ADDR];
sock = sockfd_lookup(fd, &err);
if (!sock)
goto out;
err = -EMFILE;
if (!(newsock = sock_alloc()))
goto out_put;
newsock->type = sock->type;
newsock->ops = sock->ops;
err = sock->ops->accept(sock, newsock, sock->file->f_flags);
if (err < 0)
goto out_release;
if (upeer_sockaddr) {
if(newsock->ops->getname(newsock, (struct sockaddr *)address, &len, 2)<0) {
err = -ECONNABORTED;
goto out_release;
}
err = move_addr_to_user(address, len, upeer_sockaddr, upeer_addrlen);
if (err < 0)
goto out_release;
}
/* File flags are not inherited via accept() unlike another OSes. */
if ((err = sock_map_fd(newsock)) < 0)
goto out_release;
out_put:
sockfd_put(sock);
out:
return err;
out_release:
sock_release(newsock);
goto out_put;
}
------------------------------------
以上介绍了“ 谁能给出这个源代码!SOCKET通讯,服务器及客户端都在自己的机器上”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3153111.html