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

📄 tdinwrite.c

📁 《CODE READING》配套书源代码 《CODE READING》配套书源代码
💻 C
字号:
// tdinwrite.cc. Test for -*- C++ -*- socket library// Copyright (C) 1992-1996 Gnanasekaran Swaminathan <gs4t@virginia.edu>//// Permission is granted to use at your own risk and distribute this software// in source and  binary forms provided  the above copyright notice and  this// paragraph are  preserved on all copies.  This software is provided "as is"// with no express or implied warranty.//// Version: 12Jan97 1.11#include <sockinet.h>#include <stdlib.h>#include <unistd.h>int main(int ac, char** av){  if (ac < 3) {    cerr << "USAGE: " << av[0] << " thostname port-number "	 << "data ... " << endl;    return 1;  }  osockinet osin (sockbuf::sock_dgram);  osin->connect (av[1], atoi (av[2]));  cout << "local: " << osin->localport() << ' ' << osin->localhost() << endl       << "peer:  " << osin->peerport() << ' ' << osin->peerhost() << endl;  // test socket options  cout << "socket type = " << osin->gettype() << endl;  cout << "socket linger time = " << osin->linger(1, 10).l_linger << endl;  cout << "socket linger time = " << osin->linger(1, 0).l_linger << endl;  cout << "socket linger time = " << osin->linger().l_linger << endl;  // cout << "socket send bufsz = " << osin->sendbufsz() << endl;  // cout << "socket recv bufsz = " << osin->recvbufsz() << endl;  cout << "socket keepalive  = " << osin->keepalive(true) << endl;  cout << "socket keepalive  = " << osin->keepalive(false) << endl;  cout << "socket clearerror = " << osin->clearerror() << endl;  cout << "socket debug = " << osin->debug(true) << endl;  cout << "socket debug = " << osin->debug(false) << endl;  cout << "socket reuse = " << osin->reuseaddr(true) << endl;  cout << "socket reuse = " << osin->reuseaddr(false) << endl;#ifdef __linux__  int timeo = 0;  osin->getopt(sockbuf::so_sndtimeo, &timeo, sizeof(timeo));  cout << "socket sendtimeo = " << timeo << endl;  osin->getopt(sockbuf::so_rcvtimeo, &timeo, sizeof(timeo));  cout << "socket recvtimeo = " << timeo << endl;#endif  osin << ac-3; av += 3;  while(*av) osin << *av++ << ' ';  osin << endl;	  return 0;}		

⌨️ 快捷键说明

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