首页
社区
课程
招聘
[求助]截获到send函数中的socket s 如果转换IP地址?
发表于: 2009-3-28 19:42 4357

[求助]截获到send函数中的socket s 如果转换IP地址?

2009-3-28 19:42
4357
int send (
SOCKET s,   //已取得s 如何取得该结构体中的IP地址呢?
const char *buf,
int len,
int flags );

谢谢大家~!

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (3)
雪    币: 182
活跃值: (55)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
2
s不是结构体。就4字节的一变量。

typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
typedef UINT_PTR SOCKET;



int PASCAL FAR getpeername (
IN SOCKET s,
OUT struct sockaddr FAR *name,
IN OUT int FAR * namelen);
2009-3-28 21:59
0
雪    币: 130
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
getsockname 获取本地的socket地址信息
getpeername 获取连接上来的客户端地址信息

getsockname
The getsockname function retrieves the local name for a socket.

int getsockname(
  SOCKET s,
  struct sockaddr* name,
  int* namelen
);

Parameters
s
[in] Descriptor identifying a socket.
name
[out] Pointer to a SOCKADDR structure that receives the address (name) of the socket.
namelen
[in, out] Size of the name buffer, in bytes.

-----------------------
getpeername
The getpeername function retrieves the name of the peer to which a socket is connected.

int getpeername(
  SOCKET s,
  struct sockaddr* name,
  int* namelen
);

Parameters
s
[in] Descriptor identifying a connected socket.
name
[out] The SOCKADDR structure that receives the name of the peer.
namelen
[in, out] Pointer to the size of the name structure, in bytes.
2009-3-28 22:23
0
雪    币: 4200
活跃值: (4178)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
谢谢 pathletboy 和 sojoo

谢谢~
2009-3-29 07:05
0
游客
登录 | 注册 方可回帖
返回
//