在C/C ++中创建具有已知端口的套接字 [英] create a socket with a known port in C/C++
本文介绍了在C/C ++中创建具有已知端口的套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些用于套接字的C ++类:一个类用于发送,另一类用于接收.我需要创建一个可以发送和接收的套接字.有人上这样的课吗?或某种提供这种功能的实现.
I have C++ classes for sockets: one class is for transmit and the other is for receive. I need to create a socket with which I can transmit and receive. Does anyone have such a class? Or some sort of implementation that provides this capability.
推荐答案
如果您需要创建应该通过特定端口而非临时端口发送的套接字,则可以发送前需要绑定套接字.
我在这里回答标题是因为文本对我来说没有意义.
If you need to create a socket that is supposed to send over a specific port and not an ephemeral port, you need to bind the socket before sending.
I am answering the title here because the text does not make sense to me.
您应该在您的类中创建套接字.
如果您正在为Window
s平台开发,请查看 ^ ].
You should create the sockets in your classes.
If you''re are developing for theWindow
s platform then have a look at the code samples provided by MSDN[^].
这篇关于在C/C ++中创建具有已知端口的套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文