netstd.h #1

  • //
  • guest/
  • perforce_software/
  • p4/
  • 2014-1/
  • net/
  • netstd.h
  • View
  • Commits
  • Open Download .zip Download (2 KB)
/*
 * Copyright 1995, 1996 Perforce Software.  All rights reserved.
 *
 * This file is part of Perforce - the FAST SCM System.
 */

/*
 * netstd.h - stdio driver for NetTransport, for use with inetd
 *
 * Classes Defined:
 *
 *	NetStdioEndPoint - a stdio subclass of NetEndPoint
 *	NetStdioTransport - a stdio subclass of NetTcpTransport
 *
 * Built upon NetTcpTransport so GetAddress/GetPeerAddress works
 * when invoked via inetd.
 */

class RunCommand;
class NetTcpSelector;

class NetStdioEndPoint : public NetEndPoint {

    public:
			NetStdioEndPoint( Error *e )
			{
				s = -1;
			        rc = 0;
			        isAccepted = false;
			}

			~NetStdioEndPoint();

	StrPtr		*GetHost() { return 0; }
	StrPtr		*GetListenAddress( int f );

	void		Listen( Error *e );
	void		ListenCheck( Error *e );
	int		CheaterCheck( const char *port );
	void		Unlisten();

	NetTransport *	Connect( Error *e );
	NetTransport *	Accept( Error *e );


	int		IsSingle() { return 1; }

    private:

	int		s;
	StrBuf		addr;
	RunCommand	*rc;

} ;

class NetStdioTransport : public NetTransport {

    public:
			NetStdioTransport( int r, int s, bool isAccept );
			~NetStdioTransport();

	StrPtr	*	GetAddress( int f );

	StrPtr	*	GetPeerAddress( int f );
	virtual bool	IsAccepted()
			{
			    return isAccepted;
			}

	void		Send( const char *buffer, int length, Error *e );
	int		Receive( char *buffer, int length, Error *e );

	void		Close();

//	No select() call for NT pipe.  (this will need a lot of native glue).
//
# if defined (OS_NT)
	void		SetBreak( KeepAlive *b ) { breakCallback = 0; }
# else
	void		SetBreak( KeepAlive *b ) { breakCallback = b; }
# endif

	int		GetSendBuffering() { return 2048; }
	int		GetRecvBuffering() { return 2048; }

	int		IsAlive();

    protected:
	bool		isAccepted;

    private:
	int		r;	// receive pipe 
	int		t;	// send pipe

	KeepAlive	*breakCallback;

	StrBuf		addr;

	NetTcpSelector	*selector;

} ;
# Change User Description Committed
#1 15902 Matt Attaway A second renaming that I will not obliterate as a badge of shame
//guest/perforce_software/p4/2014_1/net/netstd.h
#1 15901 Matt Attaway Clean up code to fit modern Workshop naming standards
//guest/perforce_software/p4/2014.1/net/netstd.h
#1 12188 Matt Attaway Move 'main' p4 into a release specific directory in prep for new releases
//guest/perforce_software/p4/net/netstd.h
#1 9129 Matt Attaway Initial commit of the 2014.1 p4/p4api source code