在indy9中,IdTCPServer能否快速得到对方计算机名?

zhgwbzhd 2010-09-20 12:26:48

AThread->Connection->Socket->Binding->PeerIP
可以得到对方的IP。

indy是否提供了可以获得计算机名的或者网卡MAC的方法??

我不想再用getnameinfo的方法来获得计算机名。
谢谢各位!
...全文
94 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jone7319 2010-09-21
  • 打赏
  • 举报
回复
目的达到就可以了
zhgwbzhd 2010-09-20
  • 打赏
  • 举报
回复
用它还要先 socket(...)。我觉得也不是太理想。

我想用 indy的话,他肯定也会有对应的socket.通过他的某个函数直接就可以获得呢??
我不懂电脑 2010-09-20
  • 打赏
  • 举报
回复
The Windows Sockets getpeername function gets the address of the peer to which a socket is connected.

int getpeername (

SOCKET s,
struct sockaddr FAR* name,
int FAR* namelen
);


Parameters

s

[in] A descriptor identifying a connected socket.

name

[out] The structure which is to receive the name of the peer.

namelen

[out] A pointer to the size of the name structure.



Remarks

getpeername retrieves the name of the peer connected to the socket s and stores it in the struct sockaddr identified by name. It can be used only on a connected socket. For datagram sockets, only the name of a peer specified in a previous connect call will be returned綼ny name specified by a previous sendto call will not be returned by getpeername.
On return, the namelen argument contains the actual size of the name returned in bytes.

Return Values

If no error occurs, getpeername returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.

Error Codes

WSANOTINITIALISED A successful WSAStartup must occur before using this function.
WSAENETDOWN The network subsystem has failed.
WSAEFAULT The name or the namelen argument is not a valid part of the user address space, or the namelen argument is too small.
WSAEINPROGRESS A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.
WSAENOTCONN The socket is not connected.
WSAENOTSOCK The descriptor is not a socket.


See Also

bind, getsockname, socket

1,317

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧