recvfrom()函数问题 [英] recvfrom() function question

查看:539
本文介绍了recvfrom()函数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在recvfrom()函数中,我可以将第二行char * buf更改为未签名的char * buf吗?我有一些示例代码正在尝试编译,并且它的statind表示,由于大小原因,缓冲区需要为无符号char *.

In the recvfrom() function can I change the second line char *buf to an unsigned char *buf? I have some sample code that I am trying to compile and it''s statind that the buffer needs to be an unsigned char* because of the size.

int recvfrom(
  __in         SOCKET s,
  __out        char *buf,
  __in         int len,
  __in         int flags,
  __out        struct sockaddr *from,
  __inout_opt  int *fromlen
);

推荐答案

您可以将unsigned char的缓冲区传递到函数,方法是:
You may pass a buffer of unsigned char to the function, this way:
  unsigned char buf[BUFFER_SIZE];
  //...
  recvfrom(s, reinterpret_cast<char>(buf), ...);
</char>


这篇关于recvfrom()函数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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