Server.cpp : Defines the entry point for the console application.
来源:互联网 发布:java future实现原理 编辑:程序博客网 时间:2024/06/08 17:09
#include "stdafx.h"
#include <WINSOCK2.H>
#include <iostream.h>
#pragma comment(lib,"ws2_32.lib")
int main(int argc, char* argv[])
{
SOCKET m_sock;
WSADATA wsaData;
if (0 !=WSAStartup(MAKEWORD(2,2),&wsaData))
{
cout<<"加载套接字失败!\n";
return 0;
}
m_sock = socket(AF_INET,SOCK_STREAM,0);
if (m_sock==INVALID_SOCKET)
{
cout<<"socket失败!\n";
return 0;
}
sockaddr_in baddr;
baddr.sin_family=AF_INET;
baddr.sin_port=htons(6789);
baddr.sin_addr.S_un.S_addr=htonl(INADDR_ANY);
if (SOCKET_ERROR==bind(m_sock,(sockaddr*)&baddr,sizeof(sockaddr_in)))
{
cout<<"bind失败!\n";
closesocket(m_sock);
WSACleanup();
return 0;
}
if (SOCKET_ERROR == listen(m_sock,5))
{
cout<<"listen失败!\n";
closesocket(m_sock);
WSACleanup();
return 0;
}
return 0;
}
- Server.cpp : Defines the entry point for the console application.
- // Server.cpp : Defines the entry point for the application.
- The attach() entry point for Solaris device driver
- The procedure entry point @Dbxdynalink@initialization$qqrv could not be
- UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?
- perhaps the designated entry point is not set
- perhaps the designated entry point is not set?
- 解决:perhaps the designated entry point is not set?
- perhaps the designated entry point is not set?
- 解决:perhaps the designated entry point is not set?
- An application error occurred on the server. The current custom error settings for this application
- A Streaming Server Application for the Elphel 313 Network Camera
- The IEEE standard for floating point arithmetic
- Preparing for the Sample Application
- the procedure entry point **(function symble) could not be located in the dynamic link library **.dl
- The procedure entry point XXX could not be located in the dynamic link library XXX.dll
- windows编程之四 WinMain: The Application Entry Poin
- A constructor that supplies default arguments for all its parameters also defines the default constructor.
- Excel宏类型的转换
- 纯用DIV弹出DIV窗口(经测试试用IE、firefox等浏览器)
- 如何编写Linux设备驱动程序
- 北大ACM poj2590
- 获取类成员函数的指针
- Server.cpp : Defines the entry point for the console application.
- struts2之2--动态方法调用
- XML解析
- SQLServer : EXEC和sp_executesql的区别
- 程序员的悲哀
- Android 安全机制
- 飞行棋控制台源码(仅作学习讨论)
- java生成PDF-支持中文及图片
- CityEngine三维建模几个常见问题解决方法(1)