This file is indexed.

/usr/include/socket++/sockstream.h is in libsocket++-dev 1.12.13-9.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
// sockstream.h -*- C++ -*- socket library
// Copyright (C) 2002 Herbert Straub
//
// 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
//
// Version: 1.2 2002-07-25 Herbert Straub 
// 	Improved Error Handling - extending the sockerr class by cOperation
// 2003-03-06 Herbert Straub
// 	adding sockbuf::getname und setname (sockname)
// 	sockbuf methods throw method name + sockname

#ifndef _SOCKSTREAM_H
#define	_SOCKSTREAM_H

#include <iostream> // must be ANSI compatible
#include <cstddef>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <cstdio>
#ifndef WIN32
#	include <sys/types.h>
#	include <sys/uio.h>
#	include <sys/socket.h>
#	define SOCKET int
#	define SOCKET_ERROR -1
#else
#	include <Wininet.h>
#	pragma comment(lib, "Wininet")
#endif

#if defined(__linux__) /*|| defined(__FreeBSD_kernel__)*/
#  define MSG_MAXIOVLEN	 16
#endif // __linux__

// socket exception classes
class sockerr {
  int  err;
  std::string text;
public:
  sockerr (int e, const char *operation = NULL): err (e) {
	if (operation != NULL) {
		text = operation;
	}
  }
  sockerr (int e, const char *operation, const char *specification) : err (e) {
	if (operation != NULL)
		text = operation;
	if (specification != NULL) {
		text += "(";
		text += specification;
		text += ")";
	}
  }
  sockerr (int e, const std::string &operation): err (e) {
	text = operation;
  }
  sockerr (const sockerr &O) {
	  err = O.err;
	  text = O.text;
  }

  const char* what () const { return "sockerr"; }
  const char* operation () const { return text.c_str(); }

//  int errno () const { return err; }
  int serrno () const { return err; } // LN
  const char* errstr () const;
  bool error (int eno) const { return eno == err; }

  bool io () const; // non-blocking and interrupt io recoverable error.
  bool arg () const; // incorrect argument supplied. recoverable error.
  bool op () const; // operational error. recovery difficult.

  bool conn () const;   // connection error
  bool addr () const;   // address error
  bool benign () const; // recoverable read/write error like EINTR etc.
};

class sockoob {
public:
  const char* what () const { return "sockoob"; }
};  

// socket address classes
struct sockaddr;

class sockAddr {
public:
  virtual		~sockAddr() {}
    
  virtual		operator void*	() const =0;
                        operator sockaddr* () const { return addr (); }
  virtual int		size 		() const =0;
  virtual int		family		() const =0;
  virtual sockaddr*     addr 		() const =0;
};

struct msghdr;

// socket buffer class
class sockbuf: public std::streambuf {
public:
  enum type {
    sock_stream	        = SOCK_STREAM,
    sock_dgram	        = SOCK_DGRAM,
    sock_raw	        = SOCK_RAW,
    sock_rdm	        = SOCK_RDM,
    sock_seqpacket      = SOCK_SEQPACKET
  };
  enum option {
    so_debug	        = SO_DEBUG,
    so_reuseaddr	= SO_REUSEADDR,
    so_keepalive	= SO_KEEPALIVE,
    so_dontroute	= SO_DONTROUTE,
    so_broadcast	= SO_BROADCAST,
    so_linger	        = SO_LINGER,
    so_oobinline	= SO_OOBINLINE,
    so_sndbuf		= SO_SNDBUF,
    so_rcvbuf		= SO_RCVBUF,
    so_error		= SO_ERROR,
    so_type		= SO_TYPE
  };	
  enum level {
    sol_socket          = SOL_SOCKET
  };
  enum msgflag {
    msg_oob		= MSG_OOB,
    msg_peek	        = MSG_PEEK,
    msg_dontroute	= MSG_DONTROUTE,

#if !(defined(__FreeBSD__) || defined(__GNU__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__APPLE__))
    msg_maxiovlen	= MSG_MAXIOVLEN
#endif
  };
  enum shuthow {
    shut_read,
    shut_write,
    shut_readwrite
  };
  enum { somaxconn	= SOMAXCONN };
  struct socklinger {
    int	l_onoff;	// option on/off
    int	l_linger;	// linger time

    socklinger (int a, int b): l_onoff (a), l_linger (b) {}
  };

  typedef char          char_type;
  typedef std::streampos     pos_type;
  typedef std::streamoff     off_type;
  typedef int           int_type;
  typedef int           seekdir;
  //  const int_type eof = EOF;
  enum { eof = EOF }; // LN

  struct sockdesc {
    int sock;
    sockdesc (int d): sock (d) {}
  };

protected:
  struct sockcnt {
    SOCKET	sock;
    int			cnt;
    int			stmo; // -1==block, 0==poll, >0 == waiting time in secs
    int			rtmo; // -1==block, 0==poll, >0 == waiting time in secs
    bool		oob;	// check for out-of-band byte while reading
    void*		gend; // end of input buffer
    void*		pend; // end of output buffer

    sockcnt(SOCKET s)
      : sock(s), cnt(1), stmo (-1), rtmo (-1), oob (false),
        gend (0), pend (0) {}
  };

  sockcnt* rep;  // counts the # refs to sock
  std::string		sockname; // name of sockbuf - Herbert Straub

#if 0
  virtual sockbuf*      setbuf (char_type* s, int_type* n);
  virtual pos_type      seekoff (off_type off,
				 seekdir way,
				 std::ios::openmode which = ios::in|ios::out);
  virtual pos_type      seekpos (pos_type sp,
		  		 std::ios::openmode which = ios::in|ios::out);
#endif

  virtual int           sync ();
  
  virtual int           showmanyc () const;
  virtual std::streamsize    xsgetn (char_type* s, std::streamsize n);
  virtual int_type      underflow ();
  virtual int_type      uflow ();

  virtual int_type      pbackfail (int_type c = eof);

  virtual std::streamsize    xsputn (const char_type* s, std::streamsize n);
  virtual int_type      overflow (int_type c = eof);

public:
                        sockbuf (const sockdesc& sd);
                        sockbuf (int domain, type, int proto);
                        sockbuf (const sockbuf&);
//  sockbuf&		operator = (const sockbuf&);
  virtual 		~sockbuf ();

  int                   sd () const { return rep->sock; }
  int                   pubsync () { return sync (); }
  virtual bool          is_open () const;
    
  virtual void		bind	(sockAddr&);
  virtual void		connect	(sockAddr&);
    
  void		        listen	(int num=somaxconn);
  virtual sockdesc	accept	();
  virtual sockdesc	accept	(sockAddr& sa);
    
  int   		read	(void* buf, int len);
  int			recv	(void* buf, int len, int msgf=0);
  int			recvfrom(sockAddr& sa,
				 void* buf, int len, int msgf=0);

#if	!defined(__linux__) && !defined(WIN32)
  int			recvmsg (msghdr* msg, int msgf=0);
  int			sendmsg	(msghdr* msg, int msgf=0);
#endif
    
  int			write	(const void* buf, int len);
  int			send	(const void* buf, int len, int msgf=0);
  int			sendto	(sockAddr& sa,
				 const void* buf, int len, int msgf=0);
    
  int			sendtimeout (int wp=-1);
  int			recvtimeout (int wp=-1);
  int			is_readready (int wp_sec, int wp_usec=0) const;
  int			is_writeready (int wp_sec, int wp_usec=0) const;
  int			is_exceptionpending (int wp_sec, int wp_usec=0) const;
    
  void		        shutdown (shuthow sh);
    
  int			getopt(int op, void* buf, int len,
			       int level=sol_socket) const;
  void		        setopt(int op, void* buf, int len,
		               int level=sol_socket) const;
    
  type		        gettype () const;
  int			clearerror () const;
  bool			debug	  () const;
  bool			debug	  (bool set) const;
  bool			reuseaddr () const;
  bool			reuseaddr (bool set) const;
  bool			keepalive () const;
  bool			keepalive (bool set) const;
  bool			dontroute () const;
  bool			dontroute (bool set) const;
  bool			broadcast () const;
  bool			broadcast (bool set) const;
  bool			oobinline () const;
  bool			oobinline (bool set) const;
  bool                  oob       () const { return rep->oob; }
  bool                  oob       (bool b);
  int			sendbufsz () const;
  int			sendbufsz (int sz)   const;
  int			recvbufsz () const;
  int			recvbufsz (int sz)   const;
  socklinger            linger    () const;
  socklinger		linger    (socklinger opt) const;
  socklinger            linger    (int onoff, int tm) const
    { return linger (socklinger (onoff, tm)); }

  bool                  atmark    () const;  
  long                  nread     () const;
  long                  howmanyc  () const;
  void                  nbio      (bool set=true) const;
  inline void		setname	  (const char *name);
  inline void		setname	  (const std::string &name);
  inline const std::string&	getname	  ();

#ifndef WIN32
  void                  async     (bool set=true) const;
	int                   pgrp      () const;
  int                   pgrp      (int new_pgrp) const;
  void                  closeonexec (bool set=true) const;
#endif
};

class isockstream: public std::istream {
protected:
//                        isockstream (): std::istream(rdbuf()), ios (0) {}
public:
                        isockstream(sockbuf* sb): std::ios (sb), std::istream(sb) {}
  virtual               ~isockstream () {}
		        
  sockbuf*		rdbuf () { return (sockbuf*)std::ios::rdbuf(); }
  sockbuf*		operator -> () { return rdbuf(); }
};

class osockstream: public std::ostream {
protected:
  //                      osockstream (): ostream(static_cast<>rdbuf()), std::ios (0) {}
public:
  			osockstream(sockbuf* sb): std::ios (sb), std::ostream(sb) {}
  virtual		~osockstream () {}

  sockbuf*		rdbuf () { return (sockbuf*)std::ios::rdbuf(); }
  sockbuf*		operator -> () { return rdbuf(); }
};

class iosockstream: public std::iostream {
protected:
                        iosockstream ();
public:
                        iosockstream(sockbuf* sb): std::ios (sb), std::iostream(sb) {}
  virtual               ~iosockstream () {}

  sockbuf*		rdbuf () { return (sockbuf*)std::ios::rdbuf(); }
  sockbuf*		operator -> () { return rdbuf(); }
};

// manipulators
extern osockstream& crlf (osockstream&);
extern osockstream& lfcr (osockstream&);

// inline

void sockbuf::setname (const char *name)
{
	sockname = name;
}
void sockbuf::setname (const std::string &name)
{
	sockname = name;
}
const std::string& sockbuf::getname ()
{
	return sockname;
}

#endif	// _SOCKSTREAM_H