c++ sockets

Socketc++
Socket c++

c++ sockets
Written by E. Lan to provide a mechanism for writing cross platform socket code. This library was originally written to only support blocking TCP sockets. Over the years it has been extended to support UDP and RAW sockets as well. This is the first official release of the library and the following functionality is supported:

* Cross platform socket support.
o Windows 95, Windows 98, Windows XP, Windows 8, Windows 10
o Linux, Unix
o Macintosh OSX
* Support for sychronious, and asychronious sockets
* Supports TCP Streams
* Supports UDP Datagrams
* Supports Raw Sockets
* Thread Safe
* Signal Safe

//============================================================================
// Name        : SendPacket.cpp
// Author      : elan
// Version     :
// Copyright   : Socket
// Description : Ansi-style
//============================================================================

#include
using namespace std;

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

 
 

int main(int argc, char **argv) {

	  int port = 5000;           /* port number to use */
	  int sock;                  /* socket desciptor */
	  int desc;                  /* file descriptor for socket */
	  int fd;                    /* file descriptor for file to send */
	  struct sockaddr_in addr;   /* socket parameters for bind */
	  struct sockaddr_in addr1;  /* socket parameters for accept */
	  int    addrlen;            /* argument to accept */
	  socklen_t clientLen;
	  struct stat stat_buf;      /* argument to fstat */
	  off_t offset = 0;          /* file offset */
	  char filename[1212];   /* filename to send */
	  int rc;




               /* holds return code of system calls */


	  /* check command line arguments, handling an optional port number */
	  if (argc == 2) {
	    port = atoi(argv[1]);
	    if (port <= 0) {
	      fprintf(stderr, "invalid port: %s
", argv[1]);
	      exit(1);
	    }
	  } else if (argc != 1) {
	    fprintf(stderr, "usage: %s [port]
", argv[0]);
	    exit(1);
	  }


	  cout << "create Internet domain socket"<
4.7/5 - (6 votes)