⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcpcmain.c

📁 DOS下的TCP/IP源代码,可以做参考.
💻 C
字号:
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <time.h>
#include <bios.h>
#include <dos.h>
#include "tcplib.h"

//========================================================
int client(char *host,int port)
{ char buf[1030],buf1[1030];
  int l;
  TCPSocket hl;
  hl=new_socket();
  if (connect_tcp(hl,host,port)!=1)
  {printf("Can't locate the HTTP server(%s)\n",host);
   release_socket(hl);
   return 0;
  }

  sprintf(buf,"Hi, This is a test of TCP Client.");
  write_tcp(hl,buf,strlen(buf),10);
  l=read_tcp_time(hl,buf1,1024,2);
  buf1[l]=0;
  printf("Received: %s\n",buf1);

  disconnect_tcp(hl);
  release_socket(hl);
  return 1;
}


int main(void)
{ char *server="202.114.6.48";
  int port=6666;
  init_tcplib();
  client(server,port);
  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -