当前位置: 技术问答>linux和unix
SOCKET编程问题,请给看一下,谢谢了
来源: 互联网 发布时间:2015-12-10
本文导语: 源码: #include #include #include #include #include #include #define DATA "half a league,half a league..." main(argc, argv) { int sock; struct sockaddr_in server; struct hostent *hp,* gethostbyname(); char buf[1024]; /* 建立套接字 */ sock = sock...
源码:
#include
#include
#include
#include
#include
#include
#define DATA "half a league,half a league..."
main(argc, argv)
{
int sock;
struct sockaddr_in server;
struct hostent *hp,* gethostbyname();
char buf[1024];
/* 建立套接字 */
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock h_addr, hp->h_length);
server.sin_port = htons(argv[2]);
if (connect(sock, (struct sockaddr*)&server, sizeof(server))
#include
#include
#include
#include
#include
#include
#define DATA "half a league,half a league..."
main(argc, argv)
{
int sock;
struct sockaddr_in server;
struct hostent *hp,* gethostbyname();
char buf[1024];
/* 建立套接字 */
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock h_addr, hp->h_length);
server.sin_port = htons(argv[2]);
if (connect(sock, (struct sockaddr*)&server, sizeof(server))