#include <iostream>

Source: Internet
Author: User

#include <iostream> #include <WinSock2.h> #pragma comment (lib, "Wsock32.lib")//Inbound file using namespace Std;    Wsadata wsadata;int retval;//return code int main () {WSAStartup (Makeword (2, 2), &wsadata);    Socket shost = socket (af_inet, sock_stream, ipproto_tcp);//Create a socket sockaddr_in servaddr;    servaddr.sin_family = af_inet;//tcp UDP protocol; Servaddr.sin_port = htons ((short) 4999);//server Port servAddr.sin_addr.s_addr = inet_addr ("127.0.0.1");//set server address RetVal =     Connect (Shost, (lpsockaddr) &servaddr, sizeof (SERVADDR));//connection server char buf[128];//data buffer int buf_size = 128;//Receive bytes    ZeroMemory (buf, buf_size);    strcpy_s (buf, "mytcp");    RetVal = Send (Shost, buf, strlen (BUF), 0);    Closesocket (Shost);    WSACleanup (); return 0;}

Null

#include <iostream>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.