C ++中的服务器-客户端套接字 [英] Server-Client socket in c++

查看:122
本文介绍了C ++中的服务器-客户端套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi ..
我在服务器客户端套接字编程中有问题...
当我将数据服务器发送到客户端时,服务器上连接了多个客户端,则所有客户端都将从recvfrom方法接收数据.第一次所有客户端将数据发送到服务器时,其成功工作,但是下一次我停用服务器,再次激活服务器,然后再次激活此过程意味着所有客户端在该客户端无法将数据发送到服务器时将数据发送到服务器.我在c ++中创建了服务器-客户端套接字.lib文件,并在VC ++中使用MFC GUI应用程序发送了数据.并在创建新的客户端矢量时将多个客户端存储在vector中.
您的问题不清楚.
我假设一旦您重新启动您的服务器.绑定绑定的套接字后,套接字地址将被更改.因此,在从服务器绑定套接字时,总是始终使用相同的值正确初始化ur socetaddr结构.


谢谢,
阿伦·P.


hi..
i have problem in server client socket programing...
multiple client attached with server when i have send data server to client then all clients will be receive data from recvfrom method.first time all clients send data to server its successfully working, but next time i have deactivate server and again active server and again same process means all client send data to server that time some client can''t send data to server. i have create server-client socket .lib file in c++ and data send with MFC GUI application in VC++. And also store multiple client in vector when create new client vector push-back the particular client in vector

解决方案

Hi frnd!

Your question is not clear.
I assume once u restart ur server. ur socketaddress will be changed whil u bind the created socket. hence initialize ur socetaddr structure properly always with the same values while u bind the socket from server.


Thanks,
Arun P.


这篇关于C ++中的服务器-客户端套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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