[请教]问个关于socket编程的问题

forkc2006 2009-04-20 08:53:19
环境是:jre6+eclipse3.3+cdt4.0+MinGW5.1.4(OS:windows xp)

编译能通过,在Debug目录下看到生成.o文件,但链接时报:Launching test.exe,说Debug目录下没exe文件

环境变量:C:\MinGW\bin

怀疑是指定环境变量非法,但上面设置没错啊,(具体配置是网上找的),除了系统环境变量还有别的原因吗?谢谢
...全文
106 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
forkc2006 2009-04-21
  • 打赏
  • 举报
回复
源码不是在二楼吗。。。
firsthym 2009-04-21
  • 打赏
  • 举报
回复
你的
#if 0
...
#else
...
#endif


啥意思呢
甘当码农 2009-04-20
  • 打赏
  • 举报
回复
给源代码,就能解决问题。
forkc2006 2009-04-20
  • 打赏
  • 举报
回复
莫非以后都得动手自己链接了,汗死
forkc2006 2009-04-20
  • 打赏
  • 举报
回复
谢谢啦
  • 打赏
  • 举报
回复
帮顶.
forkc2006 2009-04-20
  • 打赏
  • 举报
回复
代码:
#if 0
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netdb.h>
#else
#include <stdio.h>
#include <winsock.h>
#include <conio.h>
#include <io.h>
//#include <string.h>
//#include <iostream.h>
//#include <windows.h>
//#include <unistd.h>
//#include <stdlib.h>
#endif

int main(){

SOCKET sockfd;
int flag = 1;
struct sockaddr_in s;
char buf[255] = {0};
for(int i=0; i<9; i++){
buf[i] = 0xfe;
}
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if(sockfd < 0){
printf("sock error!\n");
}
setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, (const char*)&flag, sizeof(int));
s.sin_family = AF_INET;
s.sin_port = htons(9111);
s.sin_addr.s_addr = inet_addr("192.168.7.255");
//bzero(&(s.sin_zero), 8);
memset(&s, 0 , sizeof(s));
for(int i=0; i<100; i++){
sendto(sockfd, buf, sizeof(buf), 0, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
// Sleep(1000);
}
close(sockfd);

printf("end!\n");
return 0;
}
forkc2006 2009-04-20
  • 打赏
  • 举报
回复
在线等 - -b

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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