Initial
This commit is contained in:
62
socket/CACHE.CPP
Normal file
62
socket/CACHE.CPP
Normal file
@@ -0,0 +1,62 @@
|
||||
#include <socket/cache.hpp>
|
||||
|
||||
WORD ReceiveCache::receive(char *pBuffer,DWORD lengthBuffer,DWORD &itemCount,BOOL waitForData)
|
||||
{
|
||||
itemCount=0;
|
||||
if(!hasData(waitForData))return FALSE;
|
||||
if(itemsInCache()<=lengthBuffer)
|
||||
{
|
||||
::memcpy(pBuffer,&mReceiveCache[cursor()],itemsInCache());
|
||||
itemCount=itemsInCache();
|
||||
cursor(cursor()+itemsInCache());
|
||||
itemsInCache(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
::memcpy(pBuffer,&mReceiveCache[cursor()],lengthBuffer);
|
||||
itemCount=lengthBuffer;
|
||||
cursor(cursor()+lengthBuffer);
|
||||
itemsInCache(itemsInCache()-lengthBuffer);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD ReceiveCache::receive(char &charData,BOOL waitForData)
|
||||
{
|
||||
if(!hasData(waitForData))return FALSE;
|
||||
charData=mReceiveCache[cursor()];
|
||||
cursor(cursor()+1);
|
||||
itemsInCache(itemsInCache()-1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD ReceiveCache::cacheData(void)
|
||||
{
|
||||
int receiveCount;
|
||||
|
||||
while(!isReady(TRUE));
|
||||
if(!isReady(TRUE))return FALSE;
|
||||
if((receiveCount=::recv(socket(),(char*)(BYTE*)&mReceiveCache[0],mReceiveCache.size(),0L))==SOCKET_ERROR||!receiveCount)return FALSE;
|
||||
itemsInCache(receiveCount);
|
||||
cursor(0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD ReceiveCache::hasData(BOOL acquireData)
|
||||
{
|
||||
if(itemsInCache()>0)return TRUE;
|
||||
if(!isReady(FALSE)&&!acquireData)return FALSE;
|
||||
return cacheData();
|
||||
}
|
||||
|
||||
WORD ReceiveCache::isReady(WORD waitForData)const
|
||||
{
|
||||
fd_set setDescriptor;
|
||||
timeval waitTime;
|
||||
|
||||
setDescriptor.fd_count=1;
|
||||
setDescriptor.fd_array[0]=socket();
|
||||
if(waitForData){waitTime.tv_sec=WaitTime;waitTime.tv_usec=0;}
|
||||
else {waitTime.tv_sec=0;waitTime.tv_usec=500;}
|
||||
return ::select(0,&setDescriptor,0,0,&waitTime);
|
||||
}
|
||||
114
socket/CACHE.HPP
Normal file
114
socket/CACHE.HPP
Normal file
@@ -0,0 +1,114 @@
|
||||
#ifndef _SOCKET_RECEIVECACHE_HPP_
|
||||
#define _SOCKET_RECEIVECACHE_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINSOCK_HPP_
|
||||
#include <common/winsock.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_GLOBALDATA_HPP_
|
||||
#include <common/gdata.hpp>
|
||||
#endif
|
||||
|
||||
class ReceiveCache
|
||||
{
|
||||
public:
|
||||
ReceiveCache(void);
|
||||
ReceiveCache(const ReceiveCache &someReceiveCache);
|
||||
virtual ~ReceiveCache();
|
||||
SOCKET socket(void)const;
|
||||
void socket(SOCKET socket);
|
||||
void reset(void);
|
||||
WORD hasData(BOOL acquireData=TRUE);
|
||||
WORD isReady(WORD waitForData=TRUE)const;
|
||||
WORD receive(char &charData,BOOL waitForData=TRUE);
|
||||
WORD receive(char *pBuffer,DWORD lengthBuffer,DWORD &itemCount,BOOL waitForData=TRUE);
|
||||
private:
|
||||
enum {CacheSize=16384,WaitTime=1};
|
||||
ReceiveCache &operator=(const ReceiveCache &someReceiveCache);
|
||||
WORD cacheData(void);
|
||||
int itemsInCache(void)const;
|
||||
void itemsInCache(int itemsInCache);
|
||||
DWORD cursor(void)const;
|
||||
void cursor(DWORD cursor);
|
||||
|
||||
GlobalData<BYTE> mReceiveCache;
|
||||
DWORD mCursor;
|
||||
int mItemsInCache;
|
||||
SOCKET mSocket;
|
||||
};
|
||||
|
||||
inline
|
||||
ReceiveCache::ReceiveCache(void)
|
||||
: mCursor(0), mItemsInCache(0), mSocket(INVALID_SOCKET)
|
||||
{
|
||||
mReceiveCache.size(CacheSize);
|
||||
}
|
||||
|
||||
inline
|
||||
ReceiveCache::ReceiveCache(const ReceiveCache &someReceiveCache)
|
||||
{
|
||||
*this=someReceiveCache;
|
||||
}
|
||||
|
||||
inline
|
||||
ReceiveCache::~ReceiveCache()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ReceiveCache &ReceiveCache::operator=(const ReceiveCache &someReceiveCache)
|
||||
{
|
||||
mReceiveCache=someReceiveCache.mReceiveCache;
|
||||
mCursor=someReceiveCache.mCursor;
|
||||
mItemsInCache=someReceiveCache.mItemsInCache;
|
||||
mSocket=someReceiveCache.mSocket;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
SOCKET ReceiveCache::socket(void)const
|
||||
{
|
||||
return mSocket;
|
||||
}
|
||||
|
||||
inline
|
||||
void ReceiveCache::socket(SOCKET socket)
|
||||
{
|
||||
mSocket=socket;
|
||||
cursor(0);
|
||||
itemsInCache(0);
|
||||
}
|
||||
|
||||
inline
|
||||
int ReceiveCache::itemsInCache(void)const
|
||||
{
|
||||
return mItemsInCache;
|
||||
}
|
||||
|
||||
inline
|
||||
void ReceiveCache::itemsInCache(int itemsInCache)
|
||||
{
|
||||
mItemsInCache=itemsInCache;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD ReceiveCache::cursor(void)const
|
||||
{
|
||||
return mCursor;
|
||||
}
|
||||
|
||||
inline
|
||||
void ReceiveCache::cursor(DWORD cursor)
|
||||
{
|
||||
mCursor=cursor;
|
||||
}
|
||||
|
||||
inline
|
||||
void ReceiveCache::reset(void)
|
||||
{
|
||||
socket(INVALID_SOCKET);
|
||||
cursor(0);
|
||||
itemsInCache(0);
|
||||
}
|
||||
#endif
|
||||
4315
socket/DOCS/RFC1866.TXT
Normal file
4315
socket/DOCS/RFC1866.TXT
Normal file
File diff suppressed because it is too large
Load Diff
8175
socket/DOCS/RFC2068.TXT
Normal file
8175
socket/DOCS/RFC2068.TXT
Normal file
File diff suppressed because it is too large
Load Diff
4117
socket/DOCS/RFC821.TXT
Normal file
4117
socket/DOCS/RFC821.TXT
Normal file
File diff suppressed because it is too large
Load Diff
742
socket/DOCS/RFC854.TXT
Normal file
742
socket/DOCS/RFC854.TXT
Normal file
@@ -0,0 +1,742 @@
|
||||
rfc854
|
||||
|
||||
Press here to go to the top of the rfc 'tree'.
|
||||
|
||||
Network Working Group J. Postel
|
||||
Request for Comments: 854 J. Reynolds
|
||||
ISI
|
||||
Obsoletes: NIC 18639 May 1983
|
||||
|
||||
TELNET PROTOCOL SPECIFICATION
|
||||
|
||||
This RFC specifies a standard for the ARPA Internet community. Hosts on
|
||||
the ARPA Internet are expected to adopt and implement this standard.
|
||||
|
||||
INTRODUCTION
|
||||
|
||||
The purpose of the TELNET Protocol is to provide a fairly general,
|
||||
bi-directional, eight-bit byte oriented communications facility. Its
|
||||
primary goal is to allow a standard method of interfacing terminal
|
||||
devices and terminal-oriented processes to each other. It is
|
||||
envisioned that the protocol may also be used for terminal-terminal
|
||||
communication ("linking") and process-process communication
|
||||
(distributed computation).
|
||||
|
||||
GENERAL CONSIDERATIONS
|
||||
|
||||
A TELNET connection is a Transmission Control Protocol (TCP)
|
||||
connection used to transmit data with interspersed TELNET control
|
||||
information.
|
||||
|
||||
The TELNET Protocol is built upon three main ideas: first, the
|
||||
concept of a "Network Virtual Terminal"; second, the principle of
|
||||
negotiated options; and third, a symmetric view of terminals and
|
||||
processes.
|
||||
|
||||
1. When a TELNET connection is first established, each end is
|
||||
assumed to originate and terminate at a "Network Virtual Terminal",
|
||||
or NVT. An NVT is an imaginary device which provides a standard,
|
||||
network-wide, intermediate representation of a canonical terminal.
|
||||
This eliminates the need for "server" and "user" hosts to keep
|
||||
information about the characteristics of each other's terminals and
|
||||
terminal handling conventions. All hosts, both user and server, map
|
||||
their local device characteristics and conventions so as to appear to
|
||||
be dealing with an NVT over the network, and each can assume a
|
||||
similar mapping by the other party. The NVT is intended to strike a
|
||||
balance between being overly restricted (not providing hosts a rich
|
||||
enough vocabulary for mapping into their local character sets), and
|
||||
being overly inclusive (penalizing users with modest terminals).
|
||||
|
||||
NOTE: The "user" host is the host to which the physical terminal
|
||||
is normally attached, and the "server" host is the host which is
|
||||
normally providing some service. As an alternate point of view,
|
||||
|
||||
Postel & Reynolds [Page 1]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
applicable even in terminal-to-terminal or process-to-process
|
||||
communications, the "user" host is the host which initiated the
|
||||
communication.
|
||||
|
||||
2. The principle of negotiated options takes cognizance of the fact
|
||||
that many hosts will wish to provide additional services over and
|
||||
above those available within an NVT, and many users will have
|
||||
sophisticated terminals and would like to have elegant, rather than
|
||||
minimal, services. Independent of, but structured within the TELNET
|
||||
Protocol are various "options" that will be sanctioned and may be
|
||||
used with the "DO, DON'T, WILL, WON'T" structure (discussed below) to
|
||||
allow a user and server to agree to use a more elaborate (or perhaps
|
||||
just different) set of conventions for their TELNET connection. Such
|
||||
options could include changing the character set, the echo mode, etc.
|
||||
|
||||
The basic strategy for setting up the use of options is to have
|
||||
either party (or both) initiate a request that some option take
|
||||
effect. The other party may then either accept or reject the
|
||||
request. If the request is accepted the option immediately takes
|
||||
effect; if it is rejected the associated aspect of the connection
|
||||
remains as specified for an NVT. Clearly, a party may always refuse
|
||||
a request to enable, and must never refuse a request to disable some
|
||||
option since all parties must be prepared to support the NVT.
|
||||
|
||||
The syntax of option negotiation has been set up so that if both
|
||||
parties request an option simultaneously, each will see the other's
|
||||
request as the positive acknowledgment of its own.
|
||||
|
||||
3. The symmetry of the negotiation syntax can potentially lead to
|
||||
nonterminating acknowledgment loops -- each party seeing the incoming
|
||||
commands not as acknowledgments but as new requests which must be
|
||||
acknowledged. To prevent such loops, the following rules prevail:
|
||||
|
||||
a. Parties may only request a change in option status; i.e., a
|
||||
party may not send out a "request" merely to announce what mode it
|
||||
is in.
|
||||
|
||||
b. If a party receives what appears to be a request to enter some
|
||||
mode it is already in, the request should not be acknowledged.
|
||||
This non-response is essential to prevent endless loops in the
|
||||
negotiation. It is required that a response be sent to requests
|
||||
for a change of mode -- even if the mode is not changed.
|
||||
|
||||
c. Whenever one party sends an option command to a second party,
|
||||
whether as a request or an acknowledgment, and use of the option
|
||||
will have any effect on the processing of the data being sent from
|
||||
the first party to the second, then the command must be inserted
|
||||
in the data stream at the point where it is desired that it take
|
||||
|
||||
Postel & Reynolds [Page 2]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
effect. (It should be noted that some time will elapse between
|
||||
the transmission of a request and the receipt of an
|
||||
acknowledgment, which may be negative. Thus, a host may wish to
|
||||
buffer data, after requesting an option, until it learns whether
|
||||
the request is accepted or rejected, in order to hide the
|
||||
"uncertainty period" from the user.)
|
||||
|
||||
Option requests are likely to flurry back and forth when a TELNET
|
||||
connection is first established, as each party attempts to get the
|
||||
best possible service from the other party. Beyond that, however,
|
||||
options can be used to dynamically modify the characteristics of the
|
||||
connection to suit changing local conditions. For example, the NVT,
|
||||
as will be explained later, uses a transmission discipline well
|
||||
suited to the many "line at a time" applications such as BASIC, but
|
||||
poorly suited to the many "character at a time" applications such as
|
||||
NLS. A server might elect to devote the extra processor overhead
|
||||
required for a "character at a time" discipline when it was suitable
|
||||
for the local process and would negotiate an appropriate option.
|
||||
However, rather than then being permanently burdened with the extra
|
||||
processing overhead, it could switch (i.e., negotiate) back to NVT
|
||||
when the detailed control was no longer necessary.
|
||||
|
||||
It is possible for requests initiated by processes to stimulate a
|
||||
nonterminating request loop if the process responds to a rejection by
|
||||
merely re-requesting the option. To prevent such loops from
|
||||
occurring, rejected requests should not be repeated until something
|
||||
changes. Operationally, this can mean the process is running a
|
||||
different program, or the user has given another command, or whatever
|
||||
makes sense in the context of the given process and the given option.
|
||||
A good rule of thumb is that a re-request should only occur as a
|
||||
result of subsequent information from the other end of the connection
|
||||
or when demanded by local human intervention.
|
||||
|
||||
Option designers should not feel constrained by the somewhat limited
|
||||
syntax available for option negotiation. The intent of the simple
|
||||
syntax is to make it easy to have options -- since it is
|
||||
correspondingly easy to profess ignorance about them. If some
|
||||
particular option requires a richer negotiation structure than
|
||||
possible within "DO, DON'T, WILL, WON'T", the proper tack is to use
|
||||
"DO, DON'T, WILL, WON'T" to establish that both parties understand
|
||||
the option, and once this is accomplished a more exotic syntax can be
|
||||
used freely. For example, a party might send a request to alter
|
||||
(establish) line length. If it is accepted, then a different syntax
|
||||
can be used for actually negotiating the line length -- such a
|
||||
"sub-negotiation" might include fields for minimum allowable, maximum
|
||||
allowable and desired line lengths. The important concept is that
|
||||
|
||||
Postel & Reynolds [Page 3]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
such expanded negotiations should never begin until some prior
|
||||
(standard) negotiation has established that both parties are capable
|
||||
of parsing the expanded syntax.
|
||||
|
||||
In summary, WILL XXX is sent, by either party, to indicate that
|
||||
party's desire (offer) to begin performing option XXX, DO XXX and
|
||||
DON'T XXX being its positive and negative acknowledgments; similarly,
|
||||
DO XXX is sent to indicate a desire (request) that the other party
|
||||
(i.e., the recipient of the DO) begin performing option XXX, WILL XXX
|
||||
and WON'T XXX being the positive and negative acknowledgments. Since
|
||||
the NVT is what is left when no options are enabled, the DON'T and
|
||||
WON'T responses are guaranteed to leave the connection in a state
|
||||
which both ends can handle. Thus, all hosts may implement their
|
||||
TELNET processes to be totally unaware of options that are not
|
||||
supported, simply returning a rejection to (i.e., refusing) any
|
||||
option request that cannot be understood.
|
||||
|
||||
As much as possible, the TELNET protocol has been made server-user
|
||||
symmetrical so that it easily and naturally covers the user-user
|
||||
(linking) and server-server (cooperating processes) cases. It is
|
||||
hoped, but not absolutely required, that options will further this
|
||||
intent. In any case, it is explicitly acknowledged that symmetry is
|
||||
an operating principle rather than an ironclad rule.
|
||||
|
||||
A companion document, "TELNET Option Specifications," should be
|
||||
consulted for information about the procedure for establishing new
|
||||
options.
|
||||
|
||||
THE NETWORK VIRTUAL TERMINAL
|
||||
|
||||
The Network Virtual Terminal (NVT) is a bi-directional character
|
||||
device. The NVT has a printer and a keyboard. The printer responds
|
||||
to incoming data and the keyboard produces outgoing data which is
|
||||
sent over the TELNET connection and, if "echoes" are desired, to the
|
||||
NVT's printer as well. "Echoes" will not be expected to traverse the
|
||||
network (although options exist to enable a "remote" echoing mode of
|
||||
operation, no host is required to implement this option). The code
|
||||
set is seven-bit USASCII in an eight-bit field, except as modified
|
||||
herein. Any code conversion and timing considerations are local
|
||||
problems and do not affect the NVT.
|
||||
|
||||
TRANSMISSION OF DATA
|
||||
|
||||
Although a TELNET connection through the network is intrinsically
|
||||
full duplex, the NVT is to be viewed as a half-duplex device
|
||||
operating in a line-buffered mode. That is, unless and until
|
||||
|
||||
Postel & Reynolds [Page 4]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
options are negotiated to the contrary, the following default
|
||||
conditions pertain to the transmission of data over the TELNET
|
||||
connection:
|
||||
|
||||
1) Insofar as the availability of local buffer space permits,
|
||||
data should be accumulated in the host where it is generated
|
||||
until a complete line of data is ready for transmission, or
|
||||
until some locally-defined explicit signal to transmit occurs.
|
||||
This signal could be generated either by a process or by a
|
||||
human user.
|
||||
|
||||
The motivation for this rule is the high cost, to some hosts,
|
||||
of processing network input interrupts, coupled with the
|
||||
default NVT specification that "echoes" do not traverse the
|
||||
network. Thus, it is reasonable to buffer some amount of data
|
||||
at its source. Many systems take some processing action at the
|
||||
end of each input line (even line printers or card punches
|
||||
frequently tend to work this way), so the transmission should
|
||||
be triggered at the end of a line. On the other hand, a user
|
||||
or process may sometimes find it necessary or desirable to
|
||||
provide data which does not terminate at the end of a line;
|
||||
therefore implementers are cautioned to provide methods of
|
||||
locally signaling that all buffered data should be transmitted
|
||||
immediately.
|
||||
|
||||
2) When a process has completed sending data to an NVT printer
|
||||
and has no queued input from the NVT keyboard for further
|
||||
processing (i.e., when a process at one end of a TELNET
|
||||
connection cannot proceed without input from the other end),
|
||||
the process must transmit the TELNET Go Ahead (GA) command.
|
||||
|
||||
This rule is not intended to require that the TELNET GA command
|
||||
be sent from a terminal at the end of each line, since server
|
||||
hosts do not normally require a special signal (in addition to
|
||||
end-of-line or other locally-defined characters) in order to
|
||||
commence processing. Rather, the TELNET GA is designed to help
|
||||
a user's local host operate a physically half duplex terminal
|
||||
which has a "lockable" keyboard such as the IBM 2741. A
|
||||
description of this type of terminal may help to explain the
|
||||
proper use of the GA command.
|
||||
|
||||
The terminal-computer connection is always under control of
|
||||
either the user or the computer. Neither can unilaterally
|
||||
seize control from the other; rather the controlling end must
|
||||
relinguish its control explicitly. At the terminal end, the
|
||||
hardware is constructed so as to relinquish control each time
|
||||
that a "line" is terminated (i.e., when the "New Line" key is
|
||||
typed by the user). When this occurs, the attached (local)
|
||||
|
||||
Postel & Reynolds [Page 5]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
computer processes the input data, decides if output should be
|
||||
generated, and if not returns control to the terminal. If
|
||||
output should be generated, control is retained by the computer
|
||||
until all output has been transmitted.
|
||||
|
||||
The difficulties of using this type of terminal through the
|
||||
network should be obvious. The "local" computer is no longer
|
||||
able to decide whether to retain control after seeing an
|
||||
end-of-line signal or not; this decision can only be made by
|
||||
the "remote" computer which is processing the data. Therefore,
|
||||
the TELNET GA command provides a mechanism whereby the "remote"
|
||||
(server) computer can signal the "local" (user) computer that
|
||||
it is time to pass control to the user of the terminal. It
|
||||
should be transmitted at those times, and only at those times,
|
||||
when the user should be given control of the terminal. Note
|
||||
that premature transmission of the GA command may result in the
|
||||
blocking of output, since the user is likely to assume that the
|
||||
transmitting system has paused, and therefore he will fail to
|
||||
turn the line around manually.
|
||||
|
||||
The foregoing, of course, does not apply to the user-to-server
|
||||
direction of communication. In this direction, GAs may be sent at
|
||||
any time, but need not ever be sent. Also, if the TELNET
|
||||
connection is being used for process-to-process communication, GAs
|
||||
need not be sent in either direction. Finally, for
|
||||
terminal-to-terminal communication, GAs may be required in
|
||||
neither, one, or both directions. If a host plans to support
|
||||
terminal-to-terminal communication it is suggested that the host
|
||||
provide the user with a means of manually signaling that it is
|
||||
time for a GA to be sent over the TELNET connection; this,
|
||||
however, is not a requirement on the implementer of a TELNET
|
||||
process.
|
||||
|
||||
Note that the symmetry of the TELNET model requires that there is
|
||||
an NVT at each end of the TELNET connection, at least
|
||||
conceptually.
|
||||
|
||||
STANDARD REPRESENTATION OF CONTROL FUNCTIONS
|
||||
|
||||
As stated in the Introduction to this document, the primary goal
|
||||
of the TELNET protocol is the provision of a standard interfacing
|
||||
of terminal devices and terminal-oriented processes through the
|
||||
network. Early experiences with this type of interconnection have
|
||||
shown that certain functions are implemented by most servers, but
|
||||
that the methods of invoking these functions differ widely. For a
|
||||
human user who interacts with several server systems, these
|
||||
differences are highly frustrating. TELNET, therefore, defines a
|
||||
standard representation for five of these functions, as described
|
||||
|
||||
Postel & Reynolds [Page 6]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
below. These standard representations have standard, but not
|
||||
required, meanings (with the exception that the Interrupt Process
|
||||
(IP) function may be required by other protocols which use
|
||||
TELNET); that is, a system which does not provide the function to
|
||||
local users need not provide it to network users and may treat the
|
||||
standard representation for the function as a No-operation. On
|
||||
the other hand, a system which does provide the function to a
|
||||
local user is obliged to provide the same function to a network
|
||||
user who transmits the standard representation for the function.
|
||||
|
||||
Interrupt Process (IP)
|
||||
|
||||
Many systems provide a function which suspends, interrupts,
|
||||
aborts, or terminates the operation of a user process. This
|
||||
function is frequently used when a user believes his process is
|
||||
in an unending loop, or when an unwanted process has been
|
||||
inadvertently activated. IP is the standard representation for
|
||||
invoking this function. It should be noted by implementers
|
||||
that IP may be required by other protocols which use TELNET,
|
||||
and therefore should be implemented if these other protocols
|
||||
are to be supported.
|
||||
|
||||
Abort Output (AO)
|
||||
|
||||
Many systems provide a function which allows a process, which
|
||||
is generating output, to run to completion (or to reach the
|
||||
same stopping point it would reach if running to completion)
|
||||
but without sending the output to the user's terminal.
|
||||
Further, this function typically clears any output already
|
||||
produced but not yet actually printed (or displayed) on the
|
||||
user's terminal. AO is the standard representation for
|
||||
invoking this function. For example, some subsystem might
|
||||
normally accept a user's command, send a long text string to
|
||||
the user's terminal in response, and finally signal readiness
|
||||
to accept the next command by sending a "prompt" character
|
||||
(preceded by <CR><LF>) to the user's terminal. If the AO were
|
||||
received during the transmission of the text string, a
|
||||
reasonable implementation would be to suppress the remainder of
|
||||
the text string, but transmit the prompt character and the
|
||||
preceding <CR><LF>. (This is possibly in distinction to the
|
||||
action which might be taken if an IP were received; the IP
|
||||
might cause suppression of the text string and an exit from the
|
||||
subsystem.)
|
||||
|
||||
It should be noted, by server systems which provide this
|
||||
function, that there may be buffers external to the system (in
|
||||
|
||||
Postel & Reynolds [Page 7]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
the network and the user's local host) which should be cleared;
|
||||
the appropriate way to do this is to transmit the "Synch"
|
||||
signal (described below) to the user system.
|
||||
|
||||
Are You There (AYT)
|
||||
|
||||
Many systems provide a function which provides the user with
|
||||
some visible (e.g., printable) evidence that the system is
|
||||
still up and running. This function may be invoked by the user
|
||||
when the system is unexpectedly "silent" for a long time,
|
||||
because of the unanticipated (by the user) length of a
|
||||
computation, an unusually heavy system load, etc. AYT is the
|
||||
standard representation for invoking this function.
|
||||
|
||||
Erase Character (EC)
|
||||
|
||||
Many systems provide a function which deletes the last
|
||||
preceding undeleted character or "print position"* from the
|
||||
stream of data being supplied by the user. This function is
|
||||
typically used to edit keyboard input when typing mistakes are
|
||||
made. EC is the standard representation for invoking this
|
||||
function.
|
||||
|
||||
*NOTE: A "print position" may contain several characters
|
||||
which are the result of overstrikes, or of sequences such as
|
||||
<char1> BS <char2>...
|
||||
|
||||
Erase Line (EL)
|
||||
|
||||
Many systems provide a function which deletes all the data in
|
||||
the current "line" of input. This function is typically used
|
||||
to edit keyboard input. EL is the standard representation for
|
||||
invoking this function.
|
||||
|
||||
THE TELNET "SYNCH" SIGNAL
|
||||
|
||||
Most time-sharing systems provide mechanisms which allow a
|
||||
terminal user to regain control of a "runaway" process; the IP and
|
||||
AO functions described above are examples of these mechanisms.
|
||||
Such systems, when used locally, have access to all of the signals
|
||||
supplied by the user, whether these are normal characters or
|
||||
special "out of band" signals such as those supplied by the
|
||||
teletype "BREAK" key or the IBM 2741 "ATTN" key. This is not
|
||||
necessarily true when terminals are connected to the system
|
||||
through the network; the network's flow control mechanisms may
|
||||
cause such a signal to be buffered elsewhere, for example in the
|
||||
user's host.
|
||||
|
||||
Postel & Reynolds [Page 8]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
To counter this problem, the TELNET "Synch" mechanism is
|
||||
introduced. A Synch signal consists of a TCP Urgent notification,
|
||||
coupled with the TELNET command DATA MARK. The Urgent
|
||||
notification, which is not subject to the flow control pertaining
|
||||
to the TELNET connection, is used to invoke special handling of
|
||||
the data stream by the process which receives it. In this mode,
|
||||
the data stream is immediately scanned for "interesting" signals
|
||||
as defined below, discarding intervening data. The TELNET command
|
||||
DATA MARK (DM) is the synchronizing mark in the data stream which
|
||||
indicates that any special signal has already occurred and the
|
||||
recipient can return to normal processing of the data stream.
|
||||
|
||||
The Synch is sent via the TCP send operation with the Urgent
|
||||
flag set and the DM as the last (or only) data octet.
|
||||
|
||||
When several Synchs are sent in rapid succession, the Urgent
|
||||
notifications may be merged. It is not possible to count Urgents
|
||||
since the number received will be less than or equal the number
|
||||
sent. When in normal mode, a DM is a no operation; when in urgent
|
||||
mode, it signals the end of the urgent processing.
|
||||
|
||||
If TCP indicates the end of Urgent data before the DM is found,
|
||||
TELNET should continue the special handling of the data stream
|
||||
until the DM is found.
|
||||
|
||||
If TCP indicates more Urgent data after the DM is found, it can
|
||||
only be because of a subsequent Synch. TELNET should continue
|
||||
the special handling of the data stream until another DM is
|
||||
found.
|
||||
|
||||
"Interesting" signals are defined to be: the TELNET standard
|
||||
representations of IP, AO, and AYT (but not EC or EL); the local
|
||||
analogs of these standard representations (if any); all other
|
||||
TELNET commands; other site-defined signals which can be acted on
|
||||
without delaying the scan of the data stream.
|
||||
|
||||
Since one effect of the SYNCH mechanism is the discarding of
|
||||
essentially all characters (except TELNET commands) between the
|
||||
sender of the Synch and its recipient, this mechanism is specified
|
||||
as the standard way to clear the data path when that is desired.
|
||||
For example, if a user at a terminal causes an AO to be
|
||||
transmitted, the server which receives the AO (if it provides that
|
||||
function at all) should return a Synch to the user.
|
||||
|
||||
Finally, just as the TCP Urgent notification is needed at the
|
||||
TELNET level as an out-of-band signal, so other protocols which
|
||||
make use of TELNET may require a TELNET command which can be
|
||||
viewed as an out-of-band signal at a different level.
|
||||
|
||||
Postel & Reynolds [Page 9]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
By convention the sequence [IP, Synch] is to be used as such a
|
||||
signal. For example, suppose that some other protocol, which uses
|
||||
TELNET, defines the character string STOP analogously to the
|
||||
TELNET command AO. Imagine that a user of this protocol wishes a
|
||||
server to process the STOP string, but the connection is blocked
|
||||
because the server is processing other commands. The user should
|
||||
instruct his system to:
|
||||
|
||||
1. Send the TELNET IP character;
|
||||
|
||||
2. Send the TELNET SYNC sequence, that is:
|
||||
|
||||
Send the Data Mark (DM) as the only character
|
||||
in a TCP urgent mode send operation.
|
||||
|
||||
3. Send the character string STOP; and
|
||||
|
||||
4. Send the other protocol's analog of the TELNET DM, if any.
|
||||
|
||||
The user (or process acting on his behalf) must transmit the
|
||||
TELNET SYNCH sequence of step 2 above to ensure that the TELNET IP
|
||||
gets through to the server's TELNET interpreter.
|
||||
|
||||
The Urgent should wake up the TELNET process; the IP should
|
||||
wake up the next higher level process.
|
||||
|
||||
THE NVT PRINTER AND KEYBOARD
|
||||
|
||||
The NVT printer has an unspecified carriage width and page length
|
||||
and can produce representations of all 95 USASCII graphics (codes
|
||||
32 through 126). Of the 33 USASCII control codes (0 through 31
|
||||
and 127), and the 128 uncovered codes (128 through 255), the
|
||||
following have specified meaning to the NVT printer:
|
||||
|
||||
NAME CODE MEANING
|
||||
|
||||
NULL (NUL) 0 No Operation
|
||||
Line Feed (LF) 10 Moves the printer to the
|
||||
next print line, keeping the
|
||||
same horizontal position.
|
||||
Carriage Return (CR) 13 Moves the printer to the left
|
||||
margin of the current line.
|
||||
|
||||
Postel & Reynolds [Page 10]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
In addition, the following codes shall have defined, but not
|
||||
required, effects on the NVT printer. Neither end of a TELNET
|
||||
connection may assume that the other party will take, or will
|
||||
have taken, any particular action upon receipt or transmission
|
||||
of these:
|
||||
|
||||
BELL (BEL) 7 Produces an audible or
|
||||
visible signal (which does
|
||||
NOT move the print head).
|
||||
Back Space (BS) 8 Moves the print head one
|
||||
character position towards
|
||||
the left margin.
|
||||
Horizontal Tab (HT) 9 Moves the printer to the
|
||||
next horizontal tab stop.
|
||||
It remains unspecified how
|
||||
either party determines or
|
||||
establishes where such tab
|
||||
stops are located.
|
||||
Vertical Tab (VT) 11 Moves the printer to the
|
||||
next vertical tab stop. It
|
||||
remains unspecified how
|
||||
either party determines or
|
||||
establishes where such tab
|
||||
stops are located.
|
||||
Form Feed (FF) 12 Moves the printer to the top
|
||||
of the next page, keeping
|
||||
the same horizontal position.
|
||||
|
||||
All remaining codes do not cause the NVT printer to take any
|
||||
action.
|
||||
|
||||
The sequence "CR LF", as defined, will cause the NVT to be
|
||||
positioned at the left margin of the next print line (as would,
|
||||
for example, the sequence "LF CR"). However, many systems and
|
||||
terminals do not treat CR and LF independently, and will have to
|
||||
go to some effort to simulate their effect. (For example, some
|
||||
terminals do not have a CR independent of the LF, but on such
|
||||
terminals it may be possible to simulate a CR by backspacing.)
|
||||
Therefore, the sequence "CR LF" must be treated as a single "new
|
||||
line" character and used whenever their combined action is
|
||||
intended; the sequence "CR NUL" must be used where a carriage
|
||||
return alone is actually desired; and the CR character must be
|
||||
avoided in other contexts. This rule gives assurance to systems
|
||||
which must decide whether to perform a "new line" function or a
|
||||
multiple-backspace that the TELNET stream contains a character
|
||||
following a CR that will allow a rational decision.
|
||||
|
||||
Note that "CR LF" or "CR NUL" is required in both directions
|
||||
|
||||
Postel & Reynolds [Page 11]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
(in the default ASCII mode), to preserve the symmetry of the
|
||||
NVT model. Even though it may be known in some situations
|
||||
(e.g., with remote echo and suppress go ahead options in
|
||||
effect) that characters are not being sent to an actual
|
||||
printer, nonetheless, for the sake of consistency, the protocol
|
||||
requires that a NUL be inserted following a CR not followed by
|
||||
a LF in the data stream. The converse of this is that a NUL
|
||||
received in the data stream after a CR (in the absence of
|
||||
options negotiations which explicitly specify otherwise) should
|
||||
be stripped out prior to applying the NVT to local character
|
||||
set mapping.
|
||||
|
||||
The NVT keyboard has keys, or key combinations, or key sequences,
|
||||
for generating all 128 USASCII codes. Note that although many
|
||||
have no effect on the NVT printer, the NVT keyboard is capable of
|
||||
generating them.
|
||||
|
||||
In addition to these codes, the NVT keyboard shall be capable of
|
||||
generating the following additional codes which, except as noted,
|
||||
have defined, but not reguired, meanings. The actual code
|
||||
assignments for these "characters" are in the TELNET Command
|
||||
section, because they are viewed as being, in some sense, generic
|
||||
and should be available even when the data stream is interpreted
|
||||
as being some other character set.
|
||||
|
||||
Synch
|
||||
|
||||
This key allows the user to clear his data path to the other
|
||||
party. The activation of this key causes a DM (see command
|
||||
section) to be sent in the data stream and a TCP Urgent
|
||||
notification is associated with it. The pair DM-Urgent is to
|
||||
have required meaning as defined previously.
|
||||
|
||||
Break (BRK)
|
||||
|
||||
This code is provided because it is a signal outside the
|
||||
USASCII set which is currently given local meaning within many
|
||||
systems. It is intended to indicate that the Break Key or the
|
||||
Attention Key was hit. Note, however, that this is intended to
|
||||
provide a 129th code for systems which require it, not as a
|
||||
synonym for the IP standard representation.
|
||||
|
||||
Interrupt Process (IP)
|
||||
|
||||
Suspend, interrupt, abort or terminate the process to which the
|
||||
NVT is connected. Also, part of the out-of-band signal for
|
||||
other protocols which use TELNET.
|
||||
|
||||
Postel & Reynolds [Page 12]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
Abort Output (AO)
|
||||
|
||||
Allow the current process to (appear to) run to completion, but
|
||||
do not send its output to the user. Also, send a Synch to the
|
||||
user.
|
||||
|
||||
Are You There (AYT)
|
||||
|
||||
Send back to the NVT some visible (i.e., printable) evidence
|
||||
that the AYT was received.
|
||||
|
||||
Erase Character (EC)
|
||||
|
||||
The recipient should delete the last preceding undeleted
|
||||
character or "print position" from the data stream.
|
||||
|
||||
Erase Line (EL)
|
||||
|
||||
The recipient should delete characters from the data stream
|
||||
back to, but not including, the last "CR LF" sequence sent over
|
||||
the TELNET connection.
|
||||
|
||||
The spirit of these "extra" keys, and also the printer format
|
||||
effectors, is that they should represent a natural extension of
|
||||
the mapping that already must be done from "NVT" into "local".
|
||||
Just as the NVT data byte 68 (104 octal) should be mapped into
|
||||
whatever the local code for "uppercase D" is, so the EC character
|
||||
should be mapped into whatever the local "Erase Character"
|
||||
function is. Further, just as the mapping for 124 (174 octal) is
|
||||
somewhat arbitrary in an environment that has no "vertical bar"
|
||||
character, the EL character may have a somewhat arbitrary mapping
|
||||
(or none at all) if there is no local "Erase Line" facility.
|
||||
Similarly for format effectors: if the terminal actually does
|
||||
have a "Vertical Tab", then the mapping for VT is obvious, and
|
||||
only when the terminal does not have a vertical tab should the
|
||||
effect of VT be unpredictable.
|
||||
|
||||
TELNET COMMAND STRUCTURE
|
||||
|
||||
All TELNET commands consist of at least a two byte sequence: the
|
||||
"Interpret as Command" (IAC) escape character followed by the code
|
||||
for the command. The commands dealing with option negotiation are
|
||||
three byte sequences, the third byte being the code for the option
|
||||
referenced. This format was chosen so that as more comprehensive use
|
||||
of the "data space" is made -- by negotiations from the basic NVT, of
|
||||
course -- collisions of data bytes with reserved command values will
|
||||
be minimized, all such collisions requiring the inconvenience, and
|
||||
|
||||
Postel & Reynolds [Page 13]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
inefficiency, of "escaping" the data bytes into the stream. With the
|
||||
current set-up, only the IAC need be doubled to be sent as data, and
|
||||
the other 255 codes may be passed transparently.
|
||||
|
||||
The following are the defined TELNET commands. Note that these codes
|
||||
and code sequences have the indicated meaning only when immediately
|
||||
preceded by an IAC.
|
||||
|
||||
NAME CODE MEANING
|
||||
|
||||
SE 240 End of subnegotiation parameters.
|
||||
NOP 241 No operation.
|
||||
Data Mark 242 The data stream portion of a Synch.
|
||||
This should always be accompanied
|
||||
by a TCP Urgent notification.
|
||||
Break 243 NVT character BRK.
|
||||
Interrupt Process 244 The function IP.
|
||||
Abort output 245 The function AO.
|
||||
Are You There 246 The function AYT.
|
||||
Erase character 247 The function EC.
|
||||
Erase Line 248 The function EL.
|
||||
Go ahead 249 The GA signal.
|
||||
SB 250 Indicates that what follows is
|
||||
subnegotiation of the indicated
|
||||
option.
|
||||
WILL (option code) 251 Indicates the desire to begin
|
||||
performing, or confirmation that
|
||||
you are now performing, the
|
||||
indicated option.
|
||||
WON'T (option code) 252 Indicates the refusal to perform,
|
||||
or continue performing, the
|
||||
indicated option.
|
||||
DO (option code) 253 Indicates the request that the
|
||||
other party perform, or
|
||||
confirmation that you are expecting
|
||||
the other party to perform, the
|
||||
indicated option.
|
||||
DON'T (option code) 254 Indicates the demand that the
|
||||
other party stop performing,
|
||||
or confirmation that you are no
|
||||
longer expecting the other party
|
||||
to perform, the indicated option.
|
||||
IAC 255 Data Byte 255.
|
||||
|
||||
Postel & Reynolds [Page 14]
|
||||
|
||||
RFC 854 May 1983
|
||||
|
||||
CONNECTION ESTABLISHMENT
|
||||
|
||||
The TELNET TCP connection is established between the user's port U
|
||||
and the server's port L. The server listens on its well known port L
|
||||
for such connections. Since a TCP connection is full duplex and
|
||||
identified by the pair of ports, the server can engage in many
|
||||
simultaneous connections involving its port L and different user
|
||||
ports U.
|
||||
|
||||
Port Assignment
|
||||
|
||||
When used for remote user access to service hosts (i.e., remote
|
||||
terminal access) this protocol is assigned server port 23
|
||||
(27 octal). That is L=23.
|
||||
|
||||
Postel & Reynolds [Page 15]
|
||||
235
socket/DOCS/RFC856.TXT
Normal file
235
socket/DOCS/RFC856.TXT
Normal file
@@ -0,0 +1,235 @@
|
||||
<html><head><TITLE>RFC 856</TITLE>
|
||||
</head><body bgcolor="FFFFFF">
|
||||
<a href="../index.html"><img src="../rfcicon.gif" border=0 align=right></a>
|
||||
<a href="http://sunsite.auc.dk/"><img src="../hostedby.gif" border=0 align=right></a>
|
||||
<H1>RFC 856</H1>
|
||||
<p><HR>
|
||||
<pre>
|
||||
|
||||
Network Working Group J. Postel
|
||||
Request for Comments: 856 J. Reynolds
|
||||
ISI
|
||||
Obsoletes: NIC 15389 May 1983
|
||||
|
||||
TELNET BINARY TRANSMISSION
|
||||
|
||||
|
||||
This RFC specifies a standard for the ARPA Internet community. Hosts on
|
||||
the ARPA Internet are expected to adopt and implement this standard.
|
||||
|
||||
1. Command Name and Code
|
||||
|
||||
TRANSMIT-BINARY 0
|
||||
|
||||
2. Command Meanings
|
||||
|
||||
IAC WILL TRANSMIT-BINARY
|
||||
|
||||
The sender of this command REQUESTS permission to begin
|
||||
transmitting, or confirms that it will now begin transmitting
|
||||
characters which are to be interpreted as 8 bits of binary data by
|
||||
the receiver of the data.
|
||||
|
||||
IAC WON'T TRANSMIT-BINARY
|
||||
|
||||
If the connection is already being operated in binary transmission
|
||||
mode, the sender of this command DEMANDS to begin transmitting
|
||||
data characters which are to be interpreted as standard NVT ASCII
|
||||
characters by the receiver of the data. If the connection is not
|
||||
already being operated in binary transmission mode, the sender of
|
||||
this command REFUSES to begin transmitting characters which are to
|
||||
be interpreted as binary characters by the receiver of the data
|
||||
(i.e., the sender of the data demands to continue transmitting
|
||||
characters in its present mode).
|
||||
|
||||
A connection is being operated in binary transmission mode only
|
||||
when one party has requested it and the other has acknowledged it.
|
||||
|
||||
IAC DO TRANSMIT-BINARY
|
||||
|
||||
The sender of this command REQUESTS that the sender of the data
|
||||
start transmitting, or confirms that the sender of data is
|
||||
expected to transmit, characters which are to be interpreted as 8
|
||||
bits of binary data (i.e., by the party sending this command).
|
||||
|
||||
IAC DON'T TRANSMIT-BINARY
|
||||
|
||||
If the connection is already being operated in binary transmission
|
||||
mode, the sender of this command DEMANDS that the sender of the
|
||||
data start transmitting characters which are to be interpreted as
|
||||
|
||||
|
||||
Postel & Reynolds [Page 1]
|
||||
<hr>
|
||||
|
||||
|
||||
<a href="./rfc856.html">RFC 856</a> May 1983
|
||||
|
||||
|
||||
standard NVT ASCII characters by the receiver of the data (i.e.,
|
||||
the party sending this command). If the connection is not already
|
||||
being operated in binary transmission mode, the sender of this
|
||||
command DEMANDS that the sender of data continue transmitting
|
||||
characters which are to be interpreted in the present mode.
|
||||
|
||||
A connection is being operated in binary transmission mode only
|
||||
when one party has requested it and the other has acknowledged it.
|
||||
|
||||
3. Default
|
||||
|
||||
WON'T TRANSMIT-BINARY
|
||||
|
||||
DON'T TRANSMIT-BINARY
|
||||
|
||||
The connection is not operated in binary mode.
|
||||
|
||||
4. Motivation for the Option
|
||||
|
||||
It is sometimes useful to have available a binary transmission path
|
||||
within TELNET without having to utilize one of the more efficient,
|
||||
higher level protocols providing binary transmission (such as the
|
||||
File Transfer Protocol). The use of the IAC prefix within the basic
|
||||
TELNET protocol provides the option of binary transmission in a
|
||||
natural way, requiring only the addition of a mechanism by which the
|
||||
parties involved can agree to INTERPRET the characters transmitted
|
||||
over a TELNET connection as binary data.
|
||||
|
||||
5. Description of the Option
|
||||
|
||||
With the binary transmission option in effect, the receiver should
|
||||
interpret characters received from the transmitter which are not
|
||||
preceded with IAC as 8 bit binary data, with the exception of IAC
|
||||
followed by IAC which stands for the 8 bit binary data with the
|
||||
decimal value 255. IAC followed by an effective TELNET command (plus
|
||||
any additional characters required to complete the command) is still
|
||||
the command even with the binary transmission option in effect. IAC
|
||||
followed by a character which is not a defined TELNET command has the
|
||||
same meaning as IAC followed by NOP, although an IAC followed by an
|
||||
undefined command should not normally be sent in this mode.
|
||||
|
||||
6. Implementation Suggestions
|
||||
|
||||
It is foreseen that implementations of the binary transmission option
|
||||
will choose to refuse some other options (such as the EBCDIC
|
||||
transmission option) while the binary transmission option is in
|
||||
|
||||
|
||||
|
||||
|
||||
Postel & Reynolds [Page 2]
|
||||
<hr>
|
||||
|
||||
|
||||
<a href="./rfc856.html">RFC 856</a> May 1983
|
||||
|
||||
|
||||
effect. However, if a pair of hosts can understand being in binary
|
||||
transmission mode simultaneous with being in, for example, echo mode,
|
||||
then it is all right if they negotiate that combination.
|
||||
|
||||
It should be mentioned that the meanings of WON'T and DON'T are
|
||||
dependent upon whether the connection is presently being operated in
|
||||
binary mode or not. Consider a connection operating in, say, EBCDIC
|
||||
mode which involves a system which has chosen not to implement any
|
||||
knowledge of the binary command. If this system were to receive a DO
|
||||
TRANSMIT-BINARY, it would not recognize the TRANSMIT-BINARY option
|
||||
and therefore would return a WON'T TRANSMIT-BINARY. If the default
|
||||
for the WON'T TRANSMIT-BINARY were always NVT ASCII, the sender of
|
||||
the DO TRANSMIT-BINARY would expect the recipient to have switched to
|
||||
NVT ASCII, whereas the receiver of the DO TRANSMIT-BINARY would not
|
||||
make this interpretation.
|
||||
|
||||
Thus, we have the rule that when a connection is not presently
|
||||
operating in binary mode, the default (i.e., the interpretation of
|
||||
WON'T and DON'T) is to continue operating in the current mode,
|
||||
whether that is NVT ASCII, EBCDIC, or some other mode. This rule,
|
||||
however, is not applied once a connection is operating in a binary
|
||||
mode (as agreed to by both ends); this would require each end of the
|
||||
connection to maintain a stack, containing all of the encoding-method
|
||||
transitions which had previously occurred on the connection, in order
|
||||
to properly interpret a WON'T or DON'T. Thus, a WON'T or DON'T
|
||||
received after the connection is operating in binary mode causes the
|
||||
encoding method to revert to NVT ASCII.
|
||||
|
||||
It should be remembered that a TELNET connection is a two way
|
||||
communication channel. The binary transmission mode must be
|
||||
negotiated separately for each direction of data flow, if that is
|
||||
desired.
|
||||
|
||||
Implementation of the binary transmission option, as is the case with
|
||||
implementations of all other TELNET options, must follow the loop
|
||||
preventing rules given in the General Considerations section of the
|
||||
TELNET Protocol Specification.
|
||||
|
||||
Consider now some issues of binary transmission both to and from
|
||||
both a process and a terminal:
|
||||
|
||||
a. Binary transmission from a terminal.
|
||||
|
||||
The implementer of the binary transmission option should
|
||||
consider how (or whether) a terminal transmitting over a TELNET
|
||||
connection with binary transmission in effect is allowed to
|
||||
generate all eight bit characters, ignoring parity
|
||||
considerations, etc., on input from the terminal.
|
||||
|
||||
|
||||
Postel & Reynolds [Page 3]
|
||||
<hr>
|
||||
|
||||
|
||||
<a href="./rfc856.html">RFC 856</a> May 1983
|
||||
|
||||
|
||||
b. Binary transmission to a process.
|
||||
|
||||
The implementer of the binary transmission option should
|
||||
consider how (or whether) all characters are passed to a
|
||||
process receiving over a connection with binary transmission in
|
||||
effect. As an example of the possible problem, TOPS-20
|
||||
intercepts certain characters (e.g., ETX, the terminal
|
||||
control-C) at monitor level and does not pass them to the
|
||||
process.
|
||||
|
||||
c. Binary transmission from a process.
|
||||
|
||||
The implementer of the binary transmission option should
|
||||
consider how (or whether) a process transmitting over a
|
||||
connection with binary transmission in effect is allowed to
|
||||
send all eight bit characters with no characters intercepted by
|
||||
the monitor and changed to other characters. An example of
|
||||
such a conversion may be found in the TOPS-20 system where
|
||||
certain non-printing characters are normally converted to a
|
||||
Circumflex (up-arrow) followed by a printing character.
|
||||
|
||||
d. Binary transmission to a terminal.
|
||||
|
||||
The implementer of the binary transmission option should
|
||||
consider how (or whether) all characters received over a
|
||||
connection with binary transmission in effect are sent to a
|
||||
local terminal. At issue may be the addition of timing
|
||||
characters normally inserted locally, parity calculations, and
|
||||
any normal code conversion.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Postel & Reynolds [Page 4]
|
||||
<hr>
|
||||
</pre>
|
||||
121
socket/DOCS/RFC861.TXT
Normal file
121
socket/DOCS/RFC861.TXT
Normal file
@@ -0,0 +1,121 @@
|
||||
<html><head><TITLE>RFC 861</TITLE>
|
||||
</head><body bgcolor="FFFFFF">
|
||||
<a href="../index.html"><img src="../rfcicon.gif" border=0 align=right></a>
|
||||
<a href="http://sunsite.auc.dk/"><img src="../hostedby.gif" border=0 align=right></a>
|
||||
<H1>RFC 861</H1>
|
||||
<p><HR>
|
||||
<pre>
|
||||
|
||||
|
||||
Network Working Group J. Postel
|
||||
Request for Comments: 861 J. Reynolds
|
||||
ISI
|
||||
Obsoletes: NIC 16239 May 1983
|
||||
|
||||
TELNET EXTENDED OPTIONS - LIST OPTION
|
||||
|
||||
|
||||
This RFC specifies a standard for the ARPA Internet community. Hosts on
|
||||
the ARPA Internet are expected to adopt and implement this standard.
|
||||
|
||||
1. Command Name and Code
|
||||
|
||||
EXTENDED-OPTIONS-LIST (EXOPL) 255
|
||||
|
||||
2. Command Meanings
|
||||
|
||||
IAC DO EXOPL
|
||||
|
||||
The sender of this command REQUESTS that the receiver of this
|
||||
command begin negotiating, or confirms that the receiver of this
|
||||
command is expected to begin negotiating, TELNET options which are
|
||||
on the "Extended Options List".
|
||||
|
||||
IAC WILL EXOPL
|
||||
|
||||
The sender of this command requests permission to begin
|
||||
negotiating, or confirms that it will begin negotiating, TELNET
|
||||
options which are on the "Extended Options List".
|
||||
|
||||
IAC WON'T EXOPL
|
||||
|
||||
The sender of this command REFUSES to negotiate, or to continue
|
||||
negotiating, options on the "Extended Options List".
|
||||
|
||||
IAC DON'T EXOPL
|
||||
|
||||
The sender of this command DEMANDS that the receiver conduct no
|
||||
further negotiation of options on the "Extended Options List".
|
||||
|
||||
IAC SB EXOPL <subcommand>
|
||||
|
||||
The subcommand contains information required for the negotiation
|
||||
of an option of the "Extended Options List". The format of the
|
||||
subcommand is discussed in section 5 below.
|
||||
|
||||
3. Default
|
||||
|
||||
WON'T EXOPL, DON'T EXOPL
|
||||
|
||||
|
||||
|
||||
|
||||
Postel & Reynolds [Page 1]
|
||||
<hr>
|
||||
|
||||
|
||||
<a href="./rfc861.html">RFC 861</a> May 1983
|
||||
|
||||
|
||||
Negotiation of options on the "Extended Options List" is not
|
||||
permitted.
|
||||
|
||||
|
||||
4. Motivation for the Option
|
||||
|
||||
Eventually, a 257th TELNET option will be needed. This option will
|
||||
extend the option list for another 256 options in a manner which is
|
||||
easy to implement. The option is proposed now, rather than later
|
||||
(probably much later), in order to reserve the option number (255).
|
||||
|
||||
5. An Abstract Description of the Option
|
||||
|
||||
The EXOPL option has five subcommand codes: WILL, WON'T, DO, DON'T,
|
||||
and SB. They have exactly the same meanings as the TELNET commands
|
||||
with the same names, and are used in exactly the same way. For
|
||||
consistency, these subcommand codes will have the same values as the
|
||||
TELNET command codes (250-254). Thus, the format for negotiating a
|
||||
specific option on the "Extended Options List" (once both parties
|
||||
have agreed to use it) is:
|
||||
|
||||
IAC SB EXOPL DO/DON'T/WILL/WON'T/<option code> IAC SE
|
||||
|
||||
Once both sides have agreed to use the specific option specified by
|
||||
<option code>, subnegotiation may be required. In this case the
|
||||
format to be used is:
|
||||
|
||||
IAC SB EXOPL SB <option code> <parameters> SE IAC SE
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Postel & Reynolds [Page 2]
|
||||
<hr>
|
||||
</pre>
|
||||
3351
socket/DOCS/RFC959.TXT
Normal file
3351
socket/DOCS/RFC959.TXT
Normal file
File diff suppressed because it is too large
Load Diff
BIN
socket/EXEOBJ32/TDCONFIG.TD2
Normal file
BIN
socket/EXEOBJ32/TDCONFIG.TD2
Normal file
Binary file not shown.
78
socket/HOOKER.CPP
Normal file
78
socket/HOOKER.CPP
Normal file
@@ -0,0 +1,78 @@
|
||||
#include <socket/hooker.hpp>
|
||||
#include <common/winsock.hpp>
|
||||
|
||||
BlockHooker::BlockHooker(void)
|
||||
: mIsHooked(FALSE)
|
||||
{
|
||||
ProcAddress<BlockHooker> procAddress;
|
||||
mCodeGenerator.push(procAddress.getProcAddress(BlockHooker::hookProc));
|
||||
mCodeGenerator.movECX(int(this));
|
||||
mCodeGenerator.popEAX();
|
||||
mCodeGenerator.callEAX();
|
||||
mCodeGenerator.retn();
|
||||
mCodeGenerator.execute();
|
||||
}
|
||||
|
||||
BlockHooker::BlockHooker(const BlockHooker &someBlockHooker)
|
||||
{ // private implementation
|
||||
}
|
||||
|
||||
BlockHooker::~BlockHooker()
|
||||
{
|
||||
unhookBlock();
|
||||
}
|
||||
|
||||
BlockHooker &BlockHooker::operator=(const BlockHooker &/*someBlockHooker*/)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOL BlockHooker::operator==(const BlockHooker &/*someBlockHooker*/)const
|
||||
{ // private implementation
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL BlockHooker::hookProc(void)
|
||||
{
|
||||
if(mCallback.callback(CallbackData()))cancelBlockingCall();
|
||||
return yield();
|
||||
}
|
||||
|
||||
BOOL BlockHooker::yield(void)
|
||||
{
|
||||
BOOL haveMessage(FALSE);
|
||||
MSG msg;
|
||||
|
||||
while(::PeekMessage(&msg,NULL,0,0,PM_REMOVE))
|
||||
{
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
haveMessage=TRUE;
|
||||
}
|
||||
return haveMessage;
|
||||
}
|
||||
|
||||
BOOL BlockHooker::hookBlock(void)
|
||||
{
|
||||
if(mIsHooked)return FALSE;
|
||||
mIsHooked=TRUE;
|
||||
return (::WSASetBlockingHook((FARPROC)mCodeGenerator.base())?TRUE:FALSE);
|
||||
}
|
||||
|
||||
BOOL BlockHooker::unhookBlock(void)
|
||||
{
|
||||
if(!mIsHooked)return FALSE;
|
||||
mIsHooked=FALSE;
|
||||
return ::WSAUnhookBlockingHook();
|
||||
}
|
||||
|
||||
BOOL BlockHooker::isBlocking(void)
|
||||
{
|
||||
return ::WSAIsBlocking();
|
||||
}
|
||||
|
||||
BOOL BlockHooker::cancelBlockingCall(void)
|
||||
{
|
||||
return ::WSACancelBlockingCall();
|
||||
}
|
||||
|
||||
44
socket/HOOKER.HPP
Normal file
44
socket/HOOKER.HPP
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef _SOCKET_BLOCKHOOKER_HPP_
|
||||
#define _SOCKET_BLOCKHOOKER_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_CODEGEN_HPP_
|
||||
#include <common/codegen.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_CALLBACK_HPP_
|
||||
#include <common/callback.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_PROCADDRESS_HPP_
|
||||
#include <socket/procaddr.hpp>
|
||||
#endif
|
||||
|
||||
class BlockHooker
|
||||
{
|
||||
public:
|
||||
BlockHooker(void);
|
||||
virtual ~BlockHooker();
|
||||
BOOL hookBlock(void);
|
||||
BOOL unhookBlock(void);
|
||||
BOOL cancelBlocking(void);
|
||||
void setHandler(PureCallback *lpCallback);
|
||||
private:
|
||||
BlockHooker(const BlockHooker &someBlockHooker);
|
||||
BlockHooker &operator=(const BlockHooker &someBlockHooker);
|
||||
BOOL operator==(const BlockHooker &someBlockHooker)const;
|
||||
BOOL cancelBlockingCall(void);
|
||||
BOOL isBlocking(void);
|
||||
BOOL hookProc(void);
|
||||
BOOL yield(void);
|
||||
|
||||
CodeGen mCodeGenerator;
|
||||
BOOL mIsHooked;
|
||||
CallbackPointer mCallback;
|
||||
};
|
||||
|
||||
inline
|
||||
void BlockHooker::setHandler(PureCallback *lpCallback)
|
||||
{
|
||||
mCallback=CallbackPointer(lpCallback);
|
||||
}
|
||||
#endif
|
||||
52
socket/HOSTENT.CPP
Normal file
52
socket/HOSTENT.CPP
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <socket/hostent.hpp>
|
||||
|
||||
WORD HostEnt::hostByName(const String &hostName)
|
||||
{
|
||||
struct hostent *lpHostEnt;
|
||||
|
||||
if(0==(lpHostEnt=::gethostbyname((LPSTR)hostName)))return FALSE;
|
||||
if(AddressTypeInternet!=(AddressType)lpHostEnt->h_addrtype)return FALSE;
|
||||
pureName(lpHostEnt->h_name);
|
||||
pureAliases(lpHostEnt->h_aliases);
|
||||
pureAddressType(lpHostEnt->h_addrtype);
|
||||
pureLength(lpHostEnt->h_length);
|
||||
pureAddressList(lpHostEnt->h_addr_list);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD HostEnt::hostByAddress(const InternetAddress &hostAddress)
|
||||
{
|
||||
struct hostent *lpHostEnt=0;
|
||||
|
||||
try{lpHostEnt=::gethostbyaddr((char*)&((in_addr&)hostAddress),sizeof(in_addr),AddressTypeInternet);}
|
||||
catch(...){return FALSE;}
|
||||
if(!lpHostEnt)return FALSE;
|
||||
// if(0==(lpHostEnt=::gethostbyaddr((char*)&((in_addr&)hostAddress),sizeof(in_addr),AddressTypeInternet)))return FALSE;
|
||||
pureName(lpHostEnt->h_name);
|
||||
// pureAliases(lpHostEnt->h_aliases);
|
||||
pureAddressType(lpHostEnt->h_addrtype);
|
||||
pureLength(lpHostEnt->h_length);
|
||||
pureAddressList(lpHostEnt->h_addr_list);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void HostEnt::pureAliases(char **lpPureAliases)
|
||||
{
|
||||
mAliasNames.remove();
|
||||
if(!lpPureAliases)return;
|
||||
while(*(lpPureAliases))
|
||||
{
|
||||
mAliasNames.insert(&String(*lpPureAliases));
|
||||
lpPureAliases++;
|
||||
}
|
||||
}
|
||||
|
||||
void HostEnt::pureAddressList(char **lpPureAddressList)
|
||||
{
|
||||
struct in_addr *lpInAddr;
|
||||
mAddressList.remove();
|
||||
while(0!=(lpInAddr=(struct in_addr*)*lpPureAddressList++))
|
||||
mAddressList.insert(&InternetAddress(*lpInAddr));
|
||||
}
|
||||
|
||||
|
||||
184
socket/HOSTENT.HPP
Normal file
184
socket/HOSTENT.HPP
Normal file
@@ -0,0 +1,184 @@
|
||||
#ifndef _SOCKET_HOSTENT_HPP_
|
||||
#define _SOCKET_HOSTENT_HPP_
|
||||
#ifndef _COMMON_WINSOCK_HPP_
|
||||
#include <common/winsock.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_INTERNETADDRESS_HPP_
|
||||
#include <socket/inaddr.hpp>
|
||||
#endif
|
||||
|
||||
class HostEnt
|
||||
{
|
||||
public:
|
||||
enum AddressType{AddressTypeInternet=AF_INET};
|
||||
HostEnt(void);
|
||||
HostEnt(const HostEnt &someHostEnt);
|
||||
HostEnt(const String &hostName);
|
||||
HostEnt(const InternetAddress &internetAddress);
|
||||
virtual ~HostEnt();
|
||||
HostEnt &operator=(const HostEnt &someHostEnt);
|
||||
WORD operator==(const HostEnt &someHostEnt)const;
|
||||
WORD hostByName(const String &hostName);
|
||||
WORD hostByAddress(const InternetAddress &hostAddress);
|
||||
String hostName(void)const;
|
||||
Block<String> aliases(void)const;
|
||||
short addressType(void)const;
|
||||
short addressLength(void)const;
|
||||
Block<InternetAddress> addresses(void)const;
|
||||
private:
|
||||
void hostName(const String &hostName);
|
||||
void aliases(Block<String> &aliases);
|
||||
void addressType(short addressType);
|
||||
void addressLength(short addressLength);
|
||||
void addresses(Block<InternetAddress> &addresses);
|
||||
void pureName(char *lpPureName);
|
||||
void pureAliases(char **lpPureAliases);
|
||||
void pureAddressType(short pureAddressType);
|
||||
void pureLength(short pureLength);
|
||||
void pureAddressList(char **lpPureAddressList);
|
||||
|
||||
String mHostName;
|
||||
Block<String> mAliasNames;
|
||||
short mAddressType;
|
||||
short mAddressLength;
|
||||
Block<InternetAddress> mAddressList;
|
||||
};
|
||||
|
||||
inline
|
||||
HostEnt::HostEnt(void)
|
||||
: mAddressType(0), mAddressLength(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
HostEnt::HostEnt(const String &hostName)
|
||||
{
|
||||
hostByName(hostName);
|
||||
}
|
||||
|
||||
inline
|
||||
HostEnt::HostEnt(const InternetAddress &internetAddress)
|
||||
{
|
||||
hostByAddress(internetAddress);
|
||||
}
|
||||
|
||||
inline
|
||||
HostEnt::HostEnt(const HostEnt &someHostEnt)
|
||||
{
|
||||
*this=someHostEnt;
|
||||
}
|
||||
|
||||
inline
|
||||
HostEnt::~HostEnt()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
HostEnt &HostEnt::operator=(const HostEnt &someHostEnt)
|
||||
{
|
||||
hostName(someHostEnt.hostName());
|
||||
aliases(someHostEnt.aliases());
|
||||
addressType(someHostEnt.addressType());
|
||||
addressLength(someHostEnt.addressLength());
|
||||
addresses(someHostEnt.addresses());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD HostEnt::operator==(const HostEnt &someHostEnt)const
|
||||
{
|
||||
return (hostName()==someHostEnt.hostName()&&
|
||||
aliases()==someHostEnt.aliases()&&
|
||||
addressType()==someHostEnt.addressType()&&
|
||||
addressLength()==someHostEnt.addressLength()&&
|
||||
addresses()==someHostEnt.addresses());
|
||||
}
|
||||
|
||||
inline
|
||||
String HostEnt::hostName(void)const
|
||||
{
|
||||
return mHostName;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::hostName(const String &hostName)
|
||||
{
|
||||
mHostName=hostName;
|
||||
}
|
||||
|
||||
inline
|
||||
Block<String> HostEnt::aliases(void)const
|
||||
{
|
||||
return mAliasNames;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::aliases(Block<String> &aliases)
|
||||
{
|
||||
mAliasNames=aliases;
|
||||
}
|
||||
|
||||
inline
|
||||
short HostEnt::addressType(void)const
|
||||
{
|
||||
return mAddressType;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::addressType(short addressType)
|
||||
{
|
||||
mAddressType=addressType;
|
||||
}
|
||||
|
||||
inline
|
||||
short HostEnt::addressLength(void)const
|
||||
{
|
||||
return mAddressLength;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::addressLength(short addressLength)
|
||||
{
|
||||
mAddressLength=addressLength;
|
||||
}
|
||||
|
||||
inline
|
||||
Block<InternetAddress> HostEnt::addresses(void)const
|
||||
{
|
||||
return mAddressList;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::addresses(Block<InternetAddress> &addresses)
|
||||
{
|
||||
mAddressList=addresses;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::pureName(char *lpPureName)
|
||||
{
|
||||
if(!lpPureName)return;
|
||||
mHostName=lpPureName;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::pureAddressType(short pureAddressType)
|
||||
{
|
||||
addressType(pureAddressType);
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::pureLength(short pureLength)
|
||||
{
|
||||
addressLength(pureLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
214
socket/INADDR.HPP
Normal file
214
socket/INADDR.HPP
Normal file
@@ -0,0 +1,214 @@
|
||||
#ifndef _SOCKET_INTERNETADDRESS_HPP_
|
||||
#define _SOCKET_INTERNETADDRESS_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINSOCK_HPP_
|
||||
#include <common/winsock.hpp>
|
||||
#endif
|
||||
|
||||
class InternetAddress : private in_addr
|
||||
{
|
||||
public:
|
||||
InternetAddress(void);
|
||||
InternetAddress(BYTE a1,BYTE a2,BYTE a3,BYTE a4);
|
||||
InternetAddress(const InternetAddress &someInternetAddress);
|
||||
InternetAddress(const in_addr &someInAddr);
|
||||
InternetAddress(const String &dottedString);
|
||||
InternetAddress(unsigned value);
|
||||
virtual ~InternetAddress();
|
||||
InternetAddress &operator=(const InternetAddress &someInternetAddress);
|
||||
InternetAddress &operator=(const in_addr &someInAddr);
|
||||
WORD operator==(const InternetAddress &someInternetAddress)const;
|
||||
operator String(void);
|
||||
operator in_addr&(void);
|
||||
String toString(void)const;
|
||||
WORD isZero(void)const;
|
||||
void l1(unsigned value);
|
||||
unsigned l1(void)const;
|
||||
BYTE b1(void)const;
|
||||
void b1(BYTE b1);
|
||||
BYTE b2(void)const;
|
||||
void b2(BYTE b2);
|
||||
BYTE b3(void)const;
|
||||
void b3(BYTE b3);
|
||||
BYTE b4(void)const;
|
||||
void b4(BYTE b4);
|
||||
private:
|
||||
void setZero(void);
|
||||
};
|
||||
|
||||
inline
|
||||
InternetAddress::InternetAddress(void)
|
||||
{
|
||||
setZero();
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress::InternetAddress(const InternetAddress &someInternetAddress)
|
||||
{
|
||||
*this=someInternetAddress;
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress::InternetAddress(const in_addr &someInAddr)
|
||||
{
|
||||
*this=someInAddr;
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress::InternetAddress(unsigned value)
|
||||
{
|
||||
l1(value);
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress::InternetAddress(BYTE a1,BYTE a2,BYTE a3,BYTE a4)
|
||||
{
|
||||
b1(a1);
|
||||
b2(a2);
|
||||
b3(a3);
|
||||
b4(a4);
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress::InternetAddress(const String &dottedString)
|
||||
{
|
||||
DWORD internetAddress;
|
||||
|
||||
b1(0);
|
||||
b2(0);
|
||||
b3(0);
|
||||
b4(0);
|
||||
if(INADDR_NONE==(internetAddress=inet_addr((LPSTR)dottedString)))return;
|
||||
*this=(in_addr&)internetAddress;
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress::~InternetAddress()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress &InternetAddress::operator=(const InternetAddress &someInternetAddress)
|
||||
{
|
||||
b1(someInternetAddress.b1());
|
||||
b2(someInternetAddress.b2());
|
||||
b3(someInternetAddress.b3());
|
||||
b4(someInternetAddress.b4());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress &InternetAddress::operator=(const in_addr &someInAddr)
|
||||
{
|
||||
b1(someInAddr.S_un.S_un_b.s_b1);
|
||||
b2(someInAddr.S_un.S_un_b.s_b2);
|
||||
b3(someInAddr.S_un.S_un_b.s_b3);
|
||||
b4(someInAddr.S_un.S_un_b.s_b4);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD InternetAddress::operator==(const InternetAddress &someInternetAddress)const
|
||||
{
|
||||
return (b1()==someInternetAddress.b1()&&
|
||||
b2()==someInternetAddress.b2()&&
|
||||
b3()==someInternetAddress.b3()&&
|
||||
b4()==someInternetAddress.b4());
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress::operator String(void)
|
||||
{
|
||||
return toString();
|
||||
}
|
||||
|
||||
inline
|
||||
String InternetAddress::toString(void)const
|
||||
{
|
||||
return inet_ntoa((in_addr&)*this);
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress::operator in_addr&(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned InternetAddress::l1(void)const
|
||||
{
|
||||
return in_addr::S_un.S_addr;
|
||||
}
|
||||
|
||||
inline
|
||||
void InternetAddress::l1(unsigned value)
|
||||
{
|
||||
in_addr::S_un.S_addr=value;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE InternetAddress::b1(void)const
|
||||
{
|
||||
return in_addr::S_un.S_un_b.s_b1;
|
||||
}
|
||||
|
||||
inline
|
||||
void InternetAddress::b1(BYTE b1)
|
||||
{
|
||||
in_addr::S_un.S_un_b.s_b1=b1;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE InternetAddress::b2(void)const
|
||||
{
|
||||
return in_addr::S_un.S_un_b.s_b2;
|
||||
}
|
||||
|
||||
inline
|
||||
void InternetAddress::b2(BYTE b2)
|
||||
{
|
||||
in_addr::S_un.S_un_b.s_b2=b2;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE InternetAddress::b3(void)const
|
||||
{
|
||||
return in_addr::S_un.S_un_b.s_b3;
|
||||
}
|
||||
|
||||
inline
|
||||
void InternetAddress::b3(BYTE b3)
|
||||
{
|
||||
in_addr::S_un.S_un_b.s_b3=b3;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE InternetAddress::b4(void)const
|
||||
{
|
||||
return in_addr::S_un.S_un_b.s_b4;
|
||||
}
|
||||
|
||||
inline
|
||||
void InternetAddress::b4(BYTE b4)
|
||||
{
|
||||
in_addr::S_un.S_un_b.s_b4=b4;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD InternetAddress::isZero(void)const
|
||||
{
|
||||
return (!b1()&&!b2()&&!b3()&&!b4());
|
||||
}
|
||||
|
||||
inline
|
||||
void InternetAddress::setZero(void)
|
||||
{
|
||||
b1(0);
|
||||
b2(0);
|
||||
b3(0);
|
||||
b4(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
152
socket/INTSADDR.HPP
Normal file
152
socket/INTSADDR.HPP
Normal file
@@ -0,0 +1,152 @@
|
||||
#ifndef _SOCKET_INETSOCKETADDRESS_HPP_
|
||||
#define _SOCKET_INETSOCKETADDRESS_HPP_
|
||||
#ifndef _COMMON_WINSOCK_HPP_
|
||||
#include <common/winsock.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_INTERNETADDRESS_HPP_
|
||||
#include <socket/inaddr.hpp>
|
||||
#endif
|
||||
|
||||
class INETSocketAddress : private sockaddr_in
|
||||
{
|
||||
public:
|
||||
INETSocketAddress(void);
|
||||
INETSocketAddress(const INETSocketAddress &someINETSocketAddress);
|
||||
virtual ~INETSocketAddress();
|
||||
INETSocketAddress &operator=(const INETSocketAddress &someINETSocketAddress);
|
||||
WORD operator==(const INETSocketAddress &someINETSocketAddress);
|
||||
operator sockaddr_in&(void);
|
||||
short family(void)const;
|
||||
void family(short family);
|
||||
short port(void)const;
|
||||
void port(short port);
|
||||
InternetAddress internetAddress(void)const;
|
||||
void internetAddress(const InternetAddress &someInternetAddress);
|
||||
sockaddr_in &getsockaddr(void);
|
||||
String toString(void)const;
|
||||
static int length(void);
|
||||
private:
|
||||
short purePort(void)const;
|
||||
void purePort(short purePort);
|
||||
void setZero(void);
|
||||
};
|
||||
|
||||
inline
|
||||
INETSocketAddress::INETSocketAddress(void)
|
||||
{
|
||||
setZero();
|
||||
}
|
||||
|
||||
inline
|
||||
INETSocketAddress::INETSocketAddress(const INETSocketAddress &someINETSocketAddress)
|
||||
{
|
||||
*this=someINETSocketAddress;
|
||||
}
|
||||
|
||||
inline
|
||||
INETSocketAddress::~INETSocketAddress()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
INETSocketAddress &INETSocketAddress::operator=(const INETSocketAddress &someINETSocketAddress)
|
||||
{
|
||||
family(someINETSocketAddress.family());
|
||||
purePort(someINETSocketAddress.purePort());
|
||||
internetAddress(someINETSocketAddress.internetAddress());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD INETSocketAddress::operator==(const INETSocketAddress &someINETSocketAddress)
|
||||
{
|
||||
return (family()==someINETSocketAddress.family()&&
|
||||
purePort()==someINETSocketAddress.purePort()&&
|
||||
internetAddress()==someINETSocketAddress.internetAddress());
|
||||
}
|
||||
|
||||
inline
|
||||
INETSocketAddress::operator sockaddr_in&(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
short INETSocketAddress::family(void)const
|
||||
{
|
||||
return sockaddr_in::sin_family;
|
||||
}
|
||||
|
||||
inline
|
||||
void INETSocketAddress::family(short family)
|
||||
{
|
||||
sockaddr_in::sin_family=family;
|
||||
}
|
||||
|
||||
inline
|
||||
short INETSocketAddress::port(void)const
|
||||
{
|
||||
return ntohs(sockaddr_in::sin_port);
|
||||
}
|
||||
|
||||
inline
|
||||
void INETSocketAddress::port(short port)
|
||||
{
|
||||
sockaddr_in::sin_port=htons(port);
|
||||
}
|
||||
|
||||
inline
|
||||
short INETSocketAddress::purePort(void)const
|
||||
{
|
||||
return sockaddr_in::sin_port;
|
||||
}
|
||||
|
||||
inline
|
||||
void INETSocketAddress::purePort(short purePort)
|
||||
{
|
||||
sockaddr_in::sin_port=purePort;
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress INETSocketAddress::internetAddress(void)const
|
||||
{
|
||||
return InternetAddress(sockaddr_in::sin_addr);
|
||||
}
|
||||
|
||||
inline
|
||||
void INETSocketAddress::internetAddress(const InternetAddress &someInternetAddress)
|
||||
{
|
||||
::memcpy((char*)&(((sockaddr_in&)*this).sin_addr),(char*)&((in_addr&)someInternetAddress),sizeof(in_addr));
|
||||
}
|
||||
|
||||
inline
|
||||
sockaddr_in &INETSocketAddress::getsockaddr(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void INETSocketAddress::setZero(void)
|
||||
{
|
||||
::memset((char*)&((sockaddr_in&)*this),0,sizeof(sockaddr_in));
|
||||
}
|
||||
|
||||
inline
|
||||
String INETSocketAddress::toString(void)const
|
||||
{
|
||||
String str=internetAddress().toString()+String(":")+String().fromInt(port())+String(":");
|
||||
if(PF_INET==family())str+="PF_INET";
|
||||
else str+=String("Family:")+String().fromInt(family());
|
||||
return str;
|
||||
}
|
||||
|
||||
inline
|
||||
int INETSocketAddress::length(void)
|
||||
{
|
||||
return sizeof(sockaddr_in);
|
||||
}
|
||||
#endif
|
||||
|
||||
20
socket/PROCADDR.HPP
Normal file
20
socket/PROCADDR.HPP
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _SOCKET_PROCADDRESS_HPP_
|
||||
#define _SOCKET_PROCADDRESS_HPP_
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable:4700)
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class ProcAddress
|
||||
{
|
||||
public:
|
||||
typedef BOOL (T::*LPFNMETHODVOID)(void);
|
||||
ProcAddress(void);
|
||||
virtual ~ProcAddress();
|
||||
int getProcAddress(LPFNMETHODVOID lpfnMethod);
|
||||
private:
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
#include <socket/procaddr.tpp>
|
||||
#endif
|
||||
#endif
|
||||
34
socket/PROCADDR.TPP
Normal file
34
socket/PROCADDR.TPP
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
template <class T>
|
||||
ProcAddress<T>::ProcAddress(void)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
ProcAddress<T>::~ProcAddress()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
template <class T>
|
||||
int ProcAddress<T>::getProcAddress(LPFNMETHODVOID lpfnMethod)
|
||||
{
|
||||
typedef BOOL (*LPFNPROCVOID)(void);
|
||||
int methodAddress=*((int*)&lpfnMethod);
|
||||
return methodAddress;
|
||||
}
|
||||
#else
|
||||
template <class T>
|
||||
int ProcAddress<T>::getProcAddress(void (T::* /*lpfnMethod*/ )(void))
|
||||
{
|
||||
typedef BOOL (*LPFNPROCVOID)(void);
|
||||
int methodAddress;
|
||||
char assign[]={0x8B,0x5D,0x0C,0xC3};
|
||||
char address[]={0x00,0x00,0x00,0x00};
|
||||
*((DWORD*)address)=(DWORD)((DWORD*)assign);
|
||||
((LPFNPROCVOID)address)();
|
||||
return methodAddress;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
20
socket/RESOLVE.CPP
Normal file
20
socket/RESOLVE.CPP
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <socket/resolve.hpp>
|
||||
|
||||
void AddressResolution::resolveFTPDataAddress(void)
|
||||
{
|
||||
CSADDR_INFO *lpAddressInfo;
|
||||
char addressInfo[255];
|
||||
char aliasInfo[255];
|
||||
DWORD addressInfoBufferLength(sizeof(addressInfo));
|
||||
DWORD aliasInfoBufferLength(sizeof(aliasInfo));
|
||||
LONG addressInfoEntries;
|
||||
|
||||
::memset(&addressInfo,0,sizeof(addressInfo));
|
||||
::memset(&aliasInfo,0,sizeof(aliasInfo));
|
||||
GUID ftpDataGUID=SVCID_FTP_DATA_TCP;
|
||||
addressInfoEntries=::GetAddressByName(NS_DEFAULT,&ftpDataGUID,"ftp-data",0,RES_SERVICE,0,addressInfo,&addressInfoBufferLength,aliasInfo,&aliasInfoBufferLength);
|
||||
if(addressInfoEntries<=0)return;
|
||||
lpAddressInfo=(CSADDR_INFO*)addressInfo;
|
||||
if(!lpAddressInfo)return;
|
||||
}
|
||||
|
||||
25
socket/RESOLVE.HPP
Normal file
25
socket/RESOLVE.HPP
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _SOCKET_ADDRESSRESOLUTION_HPP_
|
||||
#define _SOCKET_ADDRESSRESOLUTION_HPP_
|
||||
#ifndef _COMMON_WINSOCK_HPP_
|
||||
#include <common/winsock.hpp>
|
||||
#endif
|
||||
|
||||
class AddressResolution
|
||||
{
|
||||
public:
|
||||
AddressResolution(void);
|
||||
~AddressResolution();
|
||||
void resolveFTPDataAddress(void);
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
AddressResolution::AddressResolution(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
AddressResolution::~AddressResolution()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
BIN
socket/Release/socket.lib
Normal file
BIN
socket/Release/socket.lib
Normal file
Binary file not shown.
BIN
socket/Release/vc60.idb
Normal file
BIN
socket/Release/vc60.idb
Normal file
Binary file not shown.
611
socket/SCRAPS.TXT
Normal file
611
socket/SCRAPS.TXT
Normal file
@@ -0,0 +1,611 @@
|
||||
DialogTemplate::operator DLGTEMPLATE *(void)
|
||||
{
|
||||
DLGTEMPLATE *lpDLGTEMPLATE(0);
|
||||
DLGITEMTEMPLATE *lpDLGITEMTEMPLATE;
|
||||
String workString;
|
||||
BYTE *lpCharByte;
|
||||
DWORD sizeData;
|
||||
|
||||
if(!itemCount())return lpDLGTEMPLATE;
|
||||
sizeData=sizeof(DLGITEMTEMPLATE)*itemCount()+sizeof(DLGTEMPLATE);
|
||||
for(short itemIndex=0;itemIndex<itemCount();itemIndex++)
|
||||
{
|
||||
sizeData+=mDlgItems[itemIndex].className().length()+1;
|
||||
sizeData+=mDlgItems[itemIndex].titleText().length()+1;
|
||||
sizeData+=2;
|
||||
}
|
||||
mItemData.size(sizeData);
|
||||
lpDLGTEMPLATE=(DLGTEMPLATE*)((BYTE*)mItemData);
|
||||
::memcpy(lpDLGTEMPLATE,&((DLGTEMPLATE&)*this),sizeof(DLGTEMPLATE));
|
||||
lpDLGITEMTEMPLATE=(DLGITEMTEMPLATE*)(((BYTE*)lpDLGTEMPLATE)+sizeof(DLGTEMPLATE));
|
||||
for(itemIndex=0;itemIndex<itemCount();itemIndex++)
|
||||
{
|
||||
DialogItemTemplate dlgItem(mDlgItems[itemIndex]);
|
||||
workString=mDlgItems[itemIndex].className();
|
||||
if(workString.isNull())continue;
|
||||
::memcpy(lpDLGITEMTEMPLATE,&dlgItem,sizeof(DLGITEMTEMPLATE));
|
||||
lpCharByte=(BYTE*)lpDLGITEMTEMPLATE;
|
||||
lpCharByte=lpCharByte+sizeof(DLGITEMTEMPLATE);
|
||||
::memcpy(lpCharByte,(LPSTR)workString,workString.length());
|
||||
lpCharByte+=workString.length();
|
||||
*lpCharByte=0;
|
||||
lpCharByte++;
|
||||
workString=mDlgItems[itemIndex].titleText();
|
||||
if(!workString.isNull())
|
||||
{
|
||||
::memcpy(lpCharByte,(LPSTR)workString,workString.length());
|
||||
lpCharByte+=workString.length();
|
||||
*lpCharByte=0;
|
||||
lpCharByte++;
|
||||
}
|
||||
else {*lpCharByte=0;lpCharByte++;}
|
||||
*((DWORD*)lpCharByte)=0;
|
||||
lpCharByte+=sizeof(DWORD);
|
||||
lpDLGITEMTEMPLATE=(DLGITEMTEMPLATE*)lpCharByte;
|
||||
}
|
||||
return lpDLGTEMPLATE;
|
||||
}
|
||||
#if 0
|
||||
void FTPClient::open(String hostName)
|
||||
{
|
||||
INETSocketAddress internetSocketAddress;
|
||||
HostEnt hostEntry;
|
||||
ServEnt serverEntry;
|
||||
String receiveString;
|
||||
|
||||
InternetAddress inetAddr;
|
||||
String stringAddress((String)inetAddr);
|
||||
message(String("trying ")+hostName+String("..."));
|
||||
if(!mWSASystem.isInitialized()){message("WINSOCK initialization failure.");return;}
|
||||
if(!hostEntry.hostByName(hostName)){message(String("no DNS entry for ")+hostName);return;}
|
||||
message(String("connect...")+String("'")+hostEntry.hostName()+String("' (")+(String)(hostEntry.addresses())[0]+String(")"));
|
||||
internetSocketAddress.internetAddress((hostEntry.addresses())[0]);
|
||||
if(!serverEntry.serviceByName("ftp","tcp")){message("cannot determine port number for ftp daemon.");return;}
|
||||
if(!mFTPControl.openSocket()){message("unable to create socket.");return;}
|
||||
internetSocketAddress.family(PF_INET);
|
||||
internetSocketAddress.port(serverEntry.port());
|
||||
if(!mFTPControl.connect(internetSocketAddress)){message("unable to connect to ftp daemon");return;}
|
||||
if(!mFTPControl.receive(receiveString)){message("error reading data from ftp daemon");return;}
|
||||
mFTPControl.getSocketName(internetSocketAddress);
|
||||
receiveString.removeTokens("\r\n");
|
||||
message(receiveString);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include <common/windows.hpp>
|
||||
#include <common/string.hpp>
|
||||
#include <winsock.h>
|
||||
|
||||
|
||||
|
||||
// *****************************
|
||||
|
||||
void finger(String userHostName);
|
||||
void ftp(String userHostName);
|
||||
void errorMessage(String messageString);
|
||||
|
||||
#if 0
|
||||
int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
|
||||
{
|
||||
WSADATA wskData;
|
||||
WORD wVersion=MAKEWORD(1,1);
|
||||
|
||||
if(!::WSAStartup(wVersion,&wskData))
|
||||
{
|
||||
ftp("sean@cnct.com");
|
||||
}
|
||||
::WSACleanup();
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void finger(String userHostName)
|
||||
{
|
||||
struct hostent FAR *lpHostEntry;
|
||||
struct sockaddr_in anaddr;
|
||||
struct servent FAR *lpServent;
|
||||
short fingerPort;
|
||||
SOCKET clientSocket;
|
||||
WORD receiveCount;
|
||||
WORD stringLength(4096);
|
||||
String receiveString;
|
||||
String userName;
|
||||
String hostName;
|
||||
|
||||
userName=userHostName.betweenString(0,'@');
|
||||
hostName=userHostName.betweenString('@','\0');
|
||||
receiveString.reserve(stringLength);
|
||||
if((lpHostEntry=::gethostbyname(hostName))==NULL){errorMessage("unknown host");return;}
|
||||
::memcpy(&anaddr.sin_addr.s_addr,lpHostEntry->h_addr,lpHostEntry->h_length);
|
||||
if((lpServent=::getservbyname("finger","tcp"))==NULL){errorMessage("cannot determine port number for finger daemon.");return;}
|
||||
fingerPort=::htons(lpServent->s_port);
|
||||
if((clientSocket=::socket(PF_INET,SOCK_STREAM,0))==INVALID_SOCKET){errorMessage("unable to create socket.");return;}
|
||||
anaddr.sin_family=PF_INET;
|
||||
anaddr.sin_port=::htons(fingerPort);
|
||||
if(::connect(clientSocket,(struct sockaddr FAR *)&anaddr,sizeof(anaddr)))
|
||||
{errorMessage("unable to connect to finger daemon");::closesocket(clientSocket);return;}
|
||||
userName+="\r\n";
|
||||
if(::send(clientSocket,userName,userName.length(),0)<userName.length())
|
||||
{errorMessage("error sending string to finger daemon");::closesocket(clientSocket);return;}
|
||||
if((receiveCount=::recv(clientSocket,receiveString,stringLength,0L))==SOCKET_ERROR)
|
||||
{errorMessage("error reading data from finger daemon");::closesocket(clientSocket);return;}
|
||||
if(!receiveCount){errorMessage("no data received from finger daemon");::closesocket(clientSocket);return;}
|
||||
receiveString+="\n";
|
||||
errorMessage(receiveString);
|
||||
::closesocket(clientSocket);
|
||||
return;
|
||||
}
|
||||
|
||||
void ftp(String userHostName)
|
||||
{
|
||||
struct hostent FAR *lpHostEntry;
|
||||
struct sockaddr_in anaddr;
|
||||
struct servent FAR *lpServent;
|
||||
short ftpPort;
|
||||
SOCKET clientSocket;
|
||||
WORD receiveCount;
|
||||
WORD stringLength(4096);
|
||||
String receiveString;
|
||||
String userName;
|
||||
String hostName;
|
||||
|
||||
userName=userHostName.betweenString(0,'@');
|
||||
hostName=userHostName.betweenString('@','\0');
|
||||
receiveString.reserve(stringLength);
|
||||
if((lpHostEntry=::gethostbyname(hostName))==NULL){errorMessage("unknown host");return;}
|
||||
::memcpy(&anaddr.sin_addr.s_addr,lpHostEntry->h_addr,lpHostEntry->h_length);
|
||||
if((lpServent=::getservbyname("ftp","tcp"))==NULL){errorMessage("cannot determine port number for ftp daemon.");return;}
|
||||
ftpPort=::htons(lpServent->s_port);
|
||||
if((clientSocket=::socket(PF_INET,SOCK_STREAM,0))==INVALID_SOCKET){errorMessage("unable to create socket.");return;}
|
||||
anaddr.sin_family=PF_INET;
|
||||
anaddr.sin_port=::htons(ftpPort);
|
||||
if(::connect(clientSocket,(struct sockaddr FAR *)&anaddr,sizeof(anaddr)))
|
||||
{errorMessage("unable to connect to ftp daemon");::closesocket(clientSocket);return;}
|
||||
if((receiveCount=::recv(clientSocket,receiveString,stringLength,0L))==SOCKET_ERROR)
|
||||
{errorMessage("error reading data from ftp daemon");::closesocket(clientSocket);return;}
|
||||
if(!receiveCount){errorMessage("no data received from ftp daemon");::closesocket(clientSocket);return;}
|
||||
errorMessage(receiveString);
|
||||
String ftpString("USER sean@cnct.com");
|
||||
ftpString+="\r\n";
|
||||
if(::send(clientSocket,ftpString,ftpString.length(),0)<ftpString.length())
|
||||
{errorMessage("error sending string to ftp daemon");::closesocket(clientSocket);return;}
|
||||
if((receiveCount=::recv(clientSocket,receiveString,stringLength,0L))==SOCKET_ERROR)
|
||||
{errorMessage("error reading data from ftp daemon");::closesocket(clientSocket);return;}
|
||||
if(!receiveCount){errorMessage("no data received from ftp daemon");::closesocket(clientSocket);return;}
|
||||
receiveString+="\n";
|
||||
errorMessage(receiveString);
|
||||
String nameString("PASS cygnus-x1");
|
||||
nameString+="\r\n";
|
||||
if(::send(clientSocket,nameString,nameString.length(),0)<nameString.length())
|
||||
{errorMessage("error sending string to ftp daemon");::closesocket(clientSocket);return;}
|
||||
if((receiveCount=::recv(clientSocket,receiveString,stringLength,0L))==SOCKET_ERROR)
|
||||
{errorMessage("error reading data from ftp daemon");::closesocket(clientSocket);return;}
|
||||
if(!receiveCount){errorMessage("no data received from ftp daemon");::closesocket(clientSocket);return;}
|
||||
receiveString+="\n";
|
||||
errorMessage(receiveString);
|
||||
::closesocket(clientSocket);
|
||||
return;
|
||||
}
|
||||
|
||||
void errorMessage(String messageString)
|
||||
{
|
||||
::MessageBox(::GetFocus(),(LPSTR)messageString,(LPSTR)"MESSAGE",MB_APPLMODAL);
|
||||
}
|
||||
|
||||
#if 0
|
||||
sizeData=sizeof(DLGITEMTEMPLATE)*itemCount()+sizeof(DLGTEMPLATE);
|
||||
sizeData+=className().length()+1;
|
||||
sizeData+=titleText().length()+1;
|
||||
sizeData+=16;
|
||||
for(short itemIndex=0;itemIndex<itemCount();itemIndex++)
|
||||
{
|
||||
sizeData+=mDlgItems[itemIndex].className().length()+1;
|
||||
sizeData+=mDlgItems[itemIndex].titleText().length()+1;
|
||||
sizeData+=16;
|
||||
}
|
||||
#endif
|
||||
|
||||
BYTE *DialogTemplate::copyString(BYTE *lpCharByte,const String &someString)const
|
||||
{
|
||||
if(!someString.isNull())
|
||||
{
|
||||
WideString wideString(someString);
|
||||
::memcpy(lpCharByte,(PureWORD*)wideString,wideString.size()*sizeof(WORD));
|
||||
lpCharByte+=wideString.size()*sizeof(WORD);
|
||||
}
|
||||
*((WORD*)lpCharByte)=0x0000;
|
||||
lpCharByte+=sizeof(WORD);
|
||||
return lpCharByte;
|
||||
}
|
||||
|
||||
DialogTemplate dlgTemplate;
|
||||
DialogItemTemplate userEdit;
|
||||
DialogItemTemplate passEdit;
|
||||
DialogItemTemplate userStatic;
|
||||
DialogItemTemplate passStatic;
|
||||
|
||||
|
||||
dlgTemplate.titleText("Login to host...");
|
||||
dlgTemplate.posRect(Rect(8,19,197,76));
|
||||
dlgTemplate.pointSize(8);
|
||||
dlgTemplate.typeFace("Helv");
|
||||
dlgTemplate.style(DS_MODALFRAME|WS_TABSTOP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_3DLOOK|DS_SETFONT|WS_POPUP);
|
||||
|
||||
userEdit.className("EDIT");
|
||||
userEdit.titleText("");
|
||||
userEdit.style(WS_BORDER|WS_TABSTOP|WS_VISIBLE|WS_CHILD);
|
||||
userEdit.posRect(Rect(56,19,98,12));
|
||||
userEdit.itemID(101);
|
||||
|
||||
passEdit.className("EDIT");
|
||||
passEdit.style(WS_BORDER|WS_TABSTOP|ES_PASSWORD|WS_CHILD|WS_VISIBLE);
|
||||
passEdit.posRect(Rect(56,35,98,12));
|
||||
passEdit.itemID(103);
|
||||
|
||||
userStatic.className("STATIC");
|
||||
userStatic.titleText("User Name :");
|
||||
userStatic.style(WS_CHILD|WS_VISIBLE);
|
||||
userStatic.posRect(Rect(2,20,39,8));
|
||||
userStatic.itemID(-1);
|
||||
|
||||
passStatic.className("STATIC");
|
||||
passStatic.titleText("Password :");
|
||||
passStatic.style(WS_CHILD|WS_VISIBLE);
|
||||
passStatic.posRect(Rect(2,36,39,8));
|
||||
passStatic.itemID(-1);
|
||||
|
||||
dlgTemplate+=userEdit;
|
||||
dlgTemplate+=passEdit;
|
||||
dlgTemplate+=userStatic;
|
||||
dlgTemplate+=passStatic;
|
||||
|
||||
DynamicDialog dynamicDialog;
|
||||
|
||||
dynamicDialog.createDialog(dlgTemplate);
|
||||
|
||||
if(!mFTPControl.isConnected())return FALSE;
|
||||
if(!putControlData(mFTPCommands[Passive]))return FALSE;
|
||||
receiveStrings();
|
||||
if(pathName.isNull())
|
||||
{
|
||||
if(!putControlData(mFTPCommands[List]))return FALSE;
|
||||
receiveStrings();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!putControlData(mFTPCommands[List]+String(" ")+pathName))return FALSE;
|
||||
receiveStrings();
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
//typedef struct _CSADDR_INFO {
|
||||
//
|
||||
// SOCKET_ADDRESS LocalAddr ;
|
||||
// SOCKET_ADDRESS RemoteAddr ;
|
||||
// INT iSocketType ;
|
||||
// INT iProtocol ;
|
||||
//} CSADDR_INFO ;
|
||||
|
||||
WORD FTPClient::port(String portDesignator)
|
||||
{
|
||||
if(!mFTPControl.isConnected())return FALSE;
|
||||
if(!putControlData(mFTPCommands[DataPort]+String(" ")+portDesignator))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD FTPClient::getControlData(void)
|
||||
{
|
||||
WORD isInMultiLine(FALSE);
|
||||
WORD processing(TRUE);
|
||||
String replyCode;
|
||||
String stringData;
|
||||
|
||||
mResponseStrings.remove();
|
||||
while(processing)
|
||||
{
|
||||
if(!mFTPControl.receive(mResponseStrings)||!mResponseStrings.size())return FALSE;
|
||||
for(short itemIndex=0;itemIndex<mResponseStrings.size();itemIndex++)
|
||||
{
|
||||
stringData=mResponseStrings[itemIndex];
|
||||
message(stringData);
|
||||
if(!isInMultiLine&&'-'==stringData[3])
|
||||
{
|
||||
isInMultiLine=TRUE;
|
||||
processing=TRUE;
|
||||
replyCode=stringData.betweenString(0,'-');
|
||||
}
|
||||
else if(isInMultiLine&&replyCode==stringData.betweenString(0,' '))
|
||||
{
|
||||
processing=FALSE;
|
||||
isInMultiLine=FALSE;
|
||||
}
|
||||
else if(!isInMultiLine)processing=FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD Socket::receive(String &receiveString)const
|
||||
{
|
||||
short receiveCount;
|
||||
BYTE rcvChar;
|
||||
|
||||
if(!isConnected())return FALSE;
|
||||
// if(!hasData())return FALSE;
|
||||
receiveString.reserve(MaxLength);
|
||||
while(TRUE)
|
||||
{
|
||||
// if(!hasData(FALSE))break;
|
||||
while(!hasData(FALSE));
|
||||
if((receiveCount=::recv(mSocket,&rcvChar,1,0L))==SOCKET_ERROR||!receiveCount)return FALSE;
|
||||
if(rcvChar==0x0D)continue;
|
||||
else if(rcvChar==0x0A)break;
|
||||
receiveString+=rcvChar;
|
||||
}
|
||||
return receiveString.length();
|
||||
}
|
||||
|
||||
void FTPData::create(void)
|
||||
{
|
||||
ServEnt serviceEntry;
|
||||
|
||||
destroy();
|
||||
if(!mWSASystem.isInitialized())return;
|
||||
if(!serviceEntry.serviceByName("ftp-data","tcp"))return;
|
||||
if(!mFTPDataSocket.openSocket())return;
|
||||
family(AF_INET);
|
||||
port(htons(serviceEntry.port()));
|
||||
if(!mFTPDataSocket.bind((INETSocketAddress&)*this))return;
|
||||
if(!mFTPDataSocket.listen())return;
|
||||
}
|
||||
|
||||
WORD ServEnt::isWINNT(void)const
|
||||
{
|
||||
OSVERSIONINFO osVersionInfo;
|
||||
::GetVersionEx(&osVersionInfo);
|
||||
return osVersionInfo.dwPlatformId==VER_PLATFORM_WIN32_NT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
WORD Socket::receive(String &receiveString)const
|
||||
{
|
||||
short receiveCount;
|
||||
char rcvChar;
|
||||
|
||||
if(!isConnected())return FALSE;
|
||||
receiveString.reserve(MaxLength);
|
||||
while(TRUE)
|
||||
{
|
||||
if(!isConnected())break;
|
||||
while(!hasData(FALSE));
|
||||
if((receiveCount=::recv(mSocket,&rcvChar,1,0L))==SOCKET_ERROR||!receiveCount)return FALSE;
|
||||
if(rcvChar==0x0D)continue;
|
||||
else if(rcvChar==0x0A)break;
|
||||
receiveString+=rcvChar;
|
||||
}
|
||||
return receiveString.length();
|
||||
}
|
||||
|
||||
#if 0
|
||||
WORD Socket::receive(String &receiveString)
|
||||
{
|
||||
short receiveCount;
|
||||
char rcvChar;
|
||||
|
||||
receiveString.reserve(MaxLength);
|
||||
while(TRUE)
|
||||
{
|
||||
if(!isConnected())return FALSE;
|
||||
while(!hasData(FALSE));
|
||||
if((receiveCount=::recv(mSocket,&rcvChar,1,0L))==SOCKET_ERROR||!receiveCount)return FALSE;
|
||||
if(rcvChar==0x0D)continue;
|
||||
else if(rcvChar==0x0A)break;
|
||||
else receiveString+=rcvChar;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
WORD Socket::hasData(WORD useWait)const
|
||||
{
|
||||
fd_set setDescriptor;
|
||||
timeval waitTime;
|
||||
|
||||
setDescriptor.fd_count=1;
|
||||
setDescriptor.fd_array[0]=mSocket;
|
||||
if(useWait){waitTime.tv_sec=2;waitTime.tv_usec=0;}
|
||||
else {waitTime.tv_sec=1;waitTime.tv_usec=500;}
|
||||
return ::select(0,&setDescriptor,0,0,&waitTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline
|
||||
WORD ReceiveCache::hasData(BOOL acquireData)
|
||||
{
|
||||
int receiveCount;
|
||||
|
||||
if(itemsInCache()>0)return TRUE;
|
||||
if(!acquireData)return FALSE;
|
||||
return cacheData();
|
||||
}
|
||||
|
||||
|
||||
if(!(itemsInCache()>0))
|
||||
{
|
||||
if(!waitForData&&!isReady(TRUE))return FALSE;
|
||||
if(!cacheData())return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//WORD Socket::hasData(WORD useWait)const
|
||||
//{
|
||||
// fd_set setDescriptor;
|
||||
// timeval waitTime;
|
||||
//
|
||||
// setDescriptor.fd_count=1;
|
||||
// setDescriptor.fd_array[0]=mSocket;
|
||||
// if(useWait){waitTime.tv_sec=WaitTime;waitTime.tv_usec=0;}
|
||||
// else {waitTime.tv_sec=0;waitTime.tv_usec=500;}
|
||||
// return ::select(0,&setDescriptor,0,0,&waitTime);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
class EchoServer : public GenericServer
|
||||
{
|
||||
public:
|
||||
EchoServer(void);
|
||||
virtual ~EchoServer();
|
||||
protected:
|
||||
WORD charHandler(const char &charData);
|
||||
void acceptHandler(void);
|
||||
void message(const String &message);
|
||||
private:
|
||||
Console mWinConsole;
|
||||
};
|
||||
|
||||
EchoServer::EchoServer(void)
|
||||
{
|
||||
}
|
||||
|
||||
EchoServer::~EchoServer()
|
||||
{
|
||||
mWinConsole.writeLine("ECHO server is destructing...");
|
||||
mWinConsole.read();
|
||||
}
|
||||
|
||||
void EchoServer::acceptHandler(void)
|
||||
{
|
||||
char charData;
|
||||
|
||||
send(TelnetPacket::InterpretAsCommand);
|
||||
send(TelnetPacket::Do);
|
||||
send(TelnetPacket::TermType);
|
||||
|
||||
send(TelnetPacket::InterpretAsCommand);
|
||||
send(TelnetPacket::Do);
|
||||
send(TelnetPacket::Authentication);
|
||||
|
||||
receive(charData);
|
||||
receive(charData);
|
||||
receive(charData);
|
||||
|
||||
receive(charData);
|
||||
receive(charData);
|
||||
receive(charData);
|
||||
|
||||
send("welcome to generic server, please login:");
|
||||
}
|
||||
|
||||
WORD EchoServer::charHandler(const char &charData)
|
||||
{
|
||||
String strVal;
|
||||
char rcvChar;
|
||||
|
||||
::sprintf(strVal,"received : (%lx)(%c)",(int)charData,charData);
|
||||
message(strVal);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void EchoServer::message(const String &message)
|
||||
{
|
||||
mWinConsole.writeLine(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
WORD FTPClient::open(String hostName)
|
||||
{
|
||||
HostEnt hostEntry;
|
||||
ServEnt serverEntry;
|
||||
|
||||
message(String("trying ")+hostName+String("..."));
|
||||
if(!mWSASystem.isInitialized()){message("WINSOCK initialization failure.");return FALSE;}
|
||||
InternetAddress internetAddress(hostName);
|
||||
if(!internetAddress.isZero()){if(!hostEntry.hostByAddress(internetAddress)){message(String("no DNS entry for ")+hostName);return FALSE;}}
|
||||
else if(!hostEntry.hostByName(hostName)){message(String("no DNS entry for ")+hostName);return FALSE;}
|
||||
message(String("connect...")+String("'")+hostEntry.hostName()+String("' (")+(String)(hostEntry.addresses())[0]+String(")"));
|
||||
INETSocketAddress::internetAddress((hostEntry.addresses())[0]);
|
||||
if(!serverEntry.serviceByName("ftp","tcp")){message("cannot determine port number for ftp daemon.");return FALSE;}
|
||||
if(!mFTPControl.openSocket()){message("unable to create socket.");return FALSE;}
|
||||
INETSocketAddress::family(PF_INET);
|
||||
INETSocketAddress::port(serverEntry.port());
|
||||
if(!mFTPControl.connect((INETSocketAddress&)*this)){message("unable to connect to ftp daemon");return FALSE;}
|
||||
if(!receive(mAckConnectionResponseStrings))return FALSE;
|
||||
mFTPControl.getSocketName((INETSocketAddress&)*this);
|
||||
return mFTPControl.isConnected();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
WORD Socket::receiveBinary(String pathFileName,TimeInfo &someTimeInfo)
|
||||
{
|
||||
Profile iniProfile;
|
||||
char rcvChar[BlockLength];
|
||||
DWORD bufferLength(sizeof(rcvChar));
|
||||
DWORD receiveCount(0);
|
||||
|
||||
if(!isConnected())return FALSE;
|
||||
// mReceiveCache.reset();
|
||||
iniProfile.makeFileName(pathFileName);
|
||||
if(pathFileName.isNull())return FALSE;
|
||||
FileHandle writeFile(pathFileName,FileHandle::Write,FileHandle::ShareNone,FileHandle::Create);
|
||||
someTimeInfo.startTime();
|
||||
while(TRUE)
|
||||
{
|
||||
while(!mReceiveCache.isReady(FALSE));
|
||||
// if((bufferLength=::recv(mSocket,rcvChar,bufferLength,0L))==SOCKET_ERROR||!bufferLength)break;
|
||||
if(!mReceiveCache.receive(rcvChar,sizeof(rcvChar),bufferLength))break;
|
||||
writeFile.write((unsigned char*)rcvChar,bufferLength);
|
||||
receiveCount+=bufferLength;
|
||||
if(!isConnected())break;
|
||||
}
|
||||
someTimeInfo.endTime(receiveCount);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
WORD Socket::receiveBinary(String pathFileName,DWORD sizeData,TimeInfo &someTimeInfo)
|
||||
{
|
||||
String strDirectory(pathFileName);
|
||||
DiskInfo diskInfo;
|
||||
Profile iniProfile;
|
||||
char rcvChar[BlockLength];
|
||||
DWORD bufferLength;
|
||||
DWORD receiveCount(0);
|
||||
|
||||
if(!isConnected())return FALSE;
|
||||
// mReceiveCache.reset();
|
||||
if(diskInfo.getDiskFreeSpace()<sizeData)return FALSE;
|
||||
if(pathFileName.isNull())return FALSE;
|
||||
if(iniProfile.makeDirectoryName(strDirectory))diskInfo.createDirectory(strDirectory);
|
||||
FileHandle writeFile(pathFileName,FileHandle::Write,FileHandle::ShareNone,FileHandle::Create);
|
||||
if(!writeFile.isOkay())return FALSE;
|
||||
someTimeInfo.startTime();
|
||||
while(receiveCount<sizeData)
|
||||
{
|
||||
if(receiveCount+sizeof(rcvChar)>sizeData)bufferLength=sizeData-receiveCount;
|
||||
else bufferLength=sizeof(rcvChar);
|
||||
while(!mReceiveCache.isReady(FALSE));
|
||||
// if((bufferLength=::recv(mSocket,rcvChar,bufferLength,0L))==SOCKET_ERROR||!bufferLength)return FALSE;
|
||||
if(!mReceiveCache.receive(rcvChar,sizeof(rcvChar),bufferLength))break;
|
||||
writeFile.write((unsigned char*)rcvChar,bufferLength);
|
||||
receiveCount+=bufferLength;
|
||||
if(!isConnected())break;
|
||||
}
|
||||
someTimeInfo.endTime(sizeData);
|
||||
return TRUE;
|
||||
}
|
||||
24
socket/SERVENT.CPP
Normal file
24
socket/SERVENT.CPP
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <socket/servent.hpp>
|
||||
|
||||
WORD ServEnt::serviceByName(const String &serviceName,const String &protocol)
|
||||
{
|
||||
struct servent *lpServent;
|
||||
|
||||
if(0==(lpServent=::getservbyname((LPSTR)serviceName,(LPSTR)protocol)))return FALSE;
|
||||
pureServiceName(lpServent->s_name);
|
||||
purePort(lpServent->s_port);
|
||||
pureAliases(lpServent->s_aliases);
|
||||
pureProtocol(lpServent->s_proto);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void ServEnt::pureAliases(char **lpAliases)
|
||||
{
|
||||
mAliasNames.remove();
|
||||
if(!lpAliases)return;
|
||||
while(*(lpAliases))
|
||||
{
|
||||
mAliasNames.insert(&String(*lpAliases));
|
||||
lpAliases++;
|
||||
}
|
||||
}
|
||||
144
socket/SERVENT.HPP
Normal file
144
socket/SERVENT.HPP
Normal file
@@ -0,0 +1,144 @@
|
||||
#ifndef _SOCKET_SERVENT_HPP_
|
||||
#define _SOCKET_SERVENT_HPP_
|
||||
#ifndef _COMMON_WINSOCK_HPP_
|
||||
#include <common/winsock.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
|
||||
class ServEnt
|
||||
{
|
||||
public:
|
||||
ServEnt(void);
|
||||
ServEnt(const ServEnt &someServEnt);
|
||||
virtual ~ServEnt();
|
||||
ServEnt &operator=(const ServEnt &someServEnt);
|
||||
WORD operator==(const ServEnt &someServEnt)const;
|
||||
WORD serviceByName(const String &serverName,const String &protocol);
|
||||
String serviceName(void)const;
|
||||
void serviceName(const String &serviceName);
|
||||
Block<String> aliases(void)const;
|
||||
void aliases(Block<String> &aliases);
|
||||
short port(void)const;
|
||||
void port(short port);
|
||||
String protocol(void)const;
|
||||
void protocol(const String &protocol);
|
||||
private:
|
||||
void pureServiceName(char *lpServiceName);
|
||||
void pureAliases(char **lpAliases);
|
||||
void purePort(short port);
|
||||
void pureProtocol(char *lpProtocol);
|
||||
|
||||
String mNameService;
|
||||
Block<String> mAliasNames;
|
||||
short mPort;
|
||||
String mProtocol;
|
||||
};
|
||||
|
||||
inline
|
||||
ServEnt::ServEnt(void)
|
||||
: mPort(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ServEnt::ServEnt(const ServEnt &someServEnt)
|
||||
{
|
||||
*this=someServEnt;
|
||||
}
|
||||
|
||||
inline
|
||||
ServEnt::~ServEnt()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ServEnt &ServEnt::operator=(const ServEnt &someServEnt)
|
||||
{
|
||||
serviceName(someServEnt.serviceName());
|
||||
aliases(someServEnt.aliases());
|
||||
port(someServEnt.port());
|
||||
protocol(someServEnt.protocol());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD ServEnt::operator==(const ServEnt &someServEnt)const
|
||||
{
|
||||
return (serviceName()==someServEnt.serviceName()&&
|
||||
aliases()==someServEnt.aliases()&&
|
||||
port()==someServEnt.port()&&
|
||||
protocol()==someServEnt.protocol());
|
||||
}
|
||||
|
||||
inline
|
||||
String ServEnt::serviceName(void)const
|
||||
{
|
||||
return mNameService;
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::serviceName(const String &serviceName)
|
||||
{
|
||||
mNameService=serviceName;
|
||||
}
|
||||
|
||||
inline
|
||||
Block<String> ServEnt::aliases(void)const
|
||||
{
|
||||
return mAliasNames;
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::aliases(Block<String> &aliases)
|
||||
{
|
||||
mAliasNames=aliases;
|
||||
}
|
||||
|
||||
inline
|
||||
short ServEnt::port(void)const
|
||||
{
|
||||
return ntohs(mPort);
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::port(short port)
|
||||
{
|
||||
mPort=htons(port);
|
||||
}
|
||||
|
||||
inline
|
||||
String ServEnt::protocol(void)const
|
||||
{
|
||||
return mProtocol;
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::protocol(const String &protocol)
|
||||
{
|
||||
mProtocol=protocol;
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::pureServiceName(char *lpServiceName)
|
||||
{
|
||||
serviceName(lpServiceName);
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::purePort(short portNumber)
|
||||
{
|
||||
mPort=portNumber;
|
||||
}
|
||||
|
||||
inline
|
||||
void ServEnt::pureProtocol(char *lpProtocol)
|
||||
{
|
||||
protocol(lpProtocol);
|
||||
}
|
||||
#endif
|
||||
|
||||
507
socket/SOCKET.BAK
Normal file
507
socket/SOCKET.BAK
Normal file
@@ -0,0 +1,507 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=socket - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to socket - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "socket - Win32 Release" && "$(CFG)" != "socket - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Socket.mak" CFG="socket - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "socket - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "socket - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "socket - Win32 Debug"
|
||||
CPP=cl.exe
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
ALL : "$(OUTDIR)\Socket.lib"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cache.obj"
|
||||
-@erase "$(INTDIR)\hooker.obj"
|
||||
-@erase "$(INTDIR)\Hostent.obj"
|
||||
-@erase "$(INTDIR)\Resolve.obj"
|
||||
-@erase "$(INTDIR)\Servent.obj"
|
||||
-@erase "$(INTDIR)\Socket.obj"
|
||||
-@erase "$(INTDIR)\Stdtmpl.obj"
|
||||
-@erase "$(INTDIR)\Wsadata.obj"
|
||||
-@erase "$(OUTDIR)\Socket.lib"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
|
||||
/Fp"$(INTDIR)/Socket.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.\.
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/Socket.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
LIB32_FLAGS=/nologo /out:"$(OUTDIR)/Socket.lib"
|
||||
LIB32_OBJS= \
|
||||
"$(INTDIR)\cache.obj" \
|
||||
"$(INTDIR)\hooker.obj" \
|
||||
"$(INTDIR)\Hostent.obj" \
|
||||
"$(INTDIR)\Resolve.obj" \
|
||||
"$(INTDIR)\Servent.obj" \
|
||||
"$(INTDIR)\Socket.obj" \
|
||||
"$(INTDIR)\Stdtmpl.obj" \
|
||||
"$(INTDIR)\Wsadata.obj"
|
||||
|
||||
"$(OUTDIR)\Socket.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
|
||||
$(LIB32) @<<
|
||||
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "msvcobj"
|
||||
# PROP Intermediate_Dir "msvcobj"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\msvcobj
|
||||
INTDIR=.\msvcobj
|
||||
|
||||
ALL : "..\exe\mssocket.lib"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cache.obj"
|
||||
-@erase "$(INTDIR)\hooker.obj"
|
||||
-@erase "$(INTDIR)\Hostent.obj"
|
||||
-@erase "$(INTDIR)\Resolve.obj"
|
||||
-@erase "$(INTDIR)\Servent.obj"
|
||||
-@erase "$(INTDIR)\Socket.obj"
|
||||
-@erase "$(INTDIR)\Stdtmpl.obj"
|
||||
-@erase "$(INTDIR)\Wsadata.obj"
|
||||
-@erase "..\exe\mssocket.lib"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /Zp1 /MTd /Z7 /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__FLAT__" /D "STRICT" /Fp"..\exe\msvc42.pch" /YX"windows.h" /c
|
||||
CPP_PROJ=/nologo /Zp1 /MTd /Z7 /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\
|
||||
"__FLAT__" /D "STRICT" /Fp"..\exe\msvc42.pch" /YX"windows.h" /Fo"$(INTDIR)/" /c\
|
||||
|
||||
CPP_OBJS=.\msvcobj/
|
||||
CPP_SBRS=.\.
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/Socket.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"..\exe\mssocket.lib"
|
||||
LIB32_FLAGS=/nologo /out:"..\exe\mssocket.lib"
|
||||
LIB32_OBJS= \
|
||||
"$(INTDIR)\cache.obj" \
|
||||
"$(INTDIR)\hooker.obj" \
|
||||
"$(INTDIR)\Hostent.obj" \
|
||||
"$(INTDIR)\Resolve.obj" \
|
||||
"$(INTDIR)\Servent.obj" \
|
||||
"$(INTDIR)\Socket.obj" \
|
||||
"$(INTDIR)\Stdtmpl.obj" \
|
||||
"$(INTDIR)\Wsadata.obj"
|
||||
|
||||
"..\exe\mssocket.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
|
||||
$(LIB32) @<<
|
||||
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Target
|
||||
|
||||
# Name "socket - Win32 Release"
|
||||
# Name "socket - Win32 Debug"
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Wsadata.cpp
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
DEP_CPP_WSADA=\
|
||||
{$(INCLUDE)}"\.\Wsadata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Wsadata.obj" : $(SOURCE) $(DEP_CPP_WSADA) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
DEP_CPP_WSADA=\
|
||||
{$(INCLUDE)}"\.\Wsadata.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Wsadata.obj" : $(SOURCE) $(DEP_CPP_WSADA) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Resolve.cpp
|
||||
DEP_CPP_RESOL=\
|
||||
{$(INCLUDE)}"\.\Resolve.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Resolve.obj" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Servent.cpp
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
DEP_CPP_SERVE=\
|
||||
{$(INCLUDE)}"\.\Servent.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Servent.obj" : $(SOURCE) $(DEP_CPP_SERVE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
DEP_CPP_SERVE=\
|
||||
{$(INCLUDE)}"\.\Servent.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Servent.obj" : $(SOURCE) $(DEP_CPP_SERVE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Socket.cpp
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
DEP_CPP_SOCKE=\
|
||||
{$(INCLUDE)}"\.\Cache.hpp"\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\.\Intsaddr.hpp"\
|
||||
{$(INCLUDE)}"\.\Socket.hpp"\
|
||||
{$(INCLUDE)}"\.\Timeinfo.hpp"\
|
||||
{$(INCLUDE)}"\.\Wsadata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\Diskinfo.hpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Filemap.hpp"\
|
||||
{$(INCLUDE)}"\Common\Filetime.hpp"\
|
||||
{$(INCLUDE)}"\Common\Finddata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Fixup.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.tpp"\
|
||||
{$(INCLUDE)}"\Common\Openfile.hpp"\
|
||||
{$(INCLUDE)}"\Common\overlap.hpp"\
|
||||
{$(INCLUDE)}"\Common\Profile.hpp"\
|
||||
{$(INCLUDE)}"\Common\Puredwrd.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.tpp"\
|
||||
{$(INCLUDE)}"\Common\Pview.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Systime.hpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Socket.obj" : $(SOURCE) $(DEP_CPP_SOCKE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
DEP_CPP_SOCKE=\
|
||||
{$(INCLUDE)}"\.\Cache.hpp"\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\.\Intsaddr.hpp"\
|
||||
{$(INCLUDE)}"\.\Socket.hpp"\
|
||||
{$(INCLUDE)}"\.\Timeinfo.hpp"\
|
||||
{$(INCLUDE)}"\.\Wsadata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\Diskinfo.hpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Filemap.hpp"\
|
||||
{$(INCLUDE)}"\Common\Filetime.hpp"\
|
||||
{$(INCLUDE)}"\Common\Finddata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Fixup.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.tpp"\
|
||||
{$(INCLUDE)}"\Common\Openfile.hpp"\
|
||||
{$(INCLUDE)}"\Common\overlap.hpp"\
|
||||
{$(INCLUDE)}"\Common\Profile.hpp"\
|
||||
{$(INCLUDE)}"\Common\Puredwrd.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.tpp"\
|
||||
{$(INCLUDE)}"\Common\Pview.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Systime.hpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Socket.obj" : $(SOURCE) $(DEP_CPP_SOCKE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Stdtmpl.cpp
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
DEP_CPP_STDTM=\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Fixup.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.tpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Stdtmpl.obj" : $(SOURCE) $(DEP_CPP_STDTM) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
DEP_CPP_STDTM=\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Fixup.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.tpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Stdtmpl.obj" : $(SOURCE) $(DEP_CPP_STDTM) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Hostent.cpp
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
DEP_CPP_HOSTE=\
|
||||
{$(INCLUDE)}"\.\Hostent.hpp"\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Hostent.obj" : $(SOURCE) $(DEP_CPP_HOSTE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
DEP_CPP_HOSTE=\
|
||||
{$(INCLUDE)}"\.\Hostent.hpp"\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Hostent.obj" : $(SOURCE) $(DEP_CPP_HOSTE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cache.cpp
|
||||
DEP_CPP_CACHE=\
|
||||
{$(INCLUDE)}"\.\Cache.hpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.tpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\cache.obj" : $(SOURCE) $(DEP_CPP_CACHE) "$(INTDIR)"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hooker.cpp
|
||||
DEP_CPP_HOOKE=\
|
||||
{$(INCLUDE)}"\.\hooker.hpp"\
|
||||
{$(INCLUDE)}"\.\procaddr.hpp"\
|
||||
{$(INCLUDE)}"\.\procaddr.tpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\common\callback.hpp"\
|
||||
{$(INCLUDE)}"\common\callback.tpp"\
|
||||
{$(INCLUDE)}"\common\cbdata.hpp"\
|
||||
{$(INCLUDE)}"\common\cbptr.hpp"\
|
||||
{$(INCLUDE)}"\common\codegen.hpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Filemap.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.tpp"\
|
||||
{$(INCLUDE)}"\common\gdipoint.hpp"\
|
||||
{$(INCLUDE)}"\common\pcallbck.hpp"\
|
||||
{$(INCLUDE)}"\common\point.hpp"\
|
||||
{$(INCLUDE)}"\Common\Puredwrd.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pview.hpp"\
|
||||
{$(INCLUDE)}"\common\rect.hpp"\
|
||||
{$(INCLUDE)}"\common\stdio.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\common\windowsx.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\hooker.obj" : $(SOURCE) $(DEP_CPP_HOOKE) "$(INTDIR)"
|
||||
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
################################################################################
|
||||
215
socket/SOCKET.HPP
Normal file
215
socket/SOCKET.HPP
Normal file
@@ -0,0 +1,215 @@
|
||||
#ifndef _SOCKET_SOCKET_HPP_
|
||||
#define _SOCKET_SOCKET_HPP_
|
||||
#ifndef _COMMON_WINSOCK_HPP_
|
||||
#include <common/winsock.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_INETSOCKETADDRESS_HPP_
|
||||
#include <socket/intsaddr.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_SOCKETADDRESS_HPP_
|
||||
#include <socket/sockaddr.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_IPMULTICAST_HPP_
|
||||
#include <socket/ipmcast.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_WSADATA_HPP_
|
||||
#include <socket/wsadata.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_TIMEINFO_HPP_
|
||||
#include <socket/timeinfo.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_RECEIVECACHE_HPP_
|
||||
#include <socket/cache.hpp>
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class Block;
|
||||
|
||||
class Socket
|
||||
{
|
||||
public:
|
||||
enum Type{SocketStream=SOCK_STREAM,SocketDGram=SOCK_DGRAM,SocketRaw=SOCK_RAW,SocketSeqPacket=SOCK_SEQPACKET,SocketRdm=SOCK_RDM};
|
||||
enum Protocol{ProtocolNone=0,ProtocolIPTCP=IPPROTO_TCP};
|
||||
enum Domain{DomainUnix=AF_UNIX,DomainInternet=AF_INET};
|
||||
enum Disposition{CloseSocket,AssumedSocket};
|
||||
enum MsgType{None=0,OutOfBand=MSG_OOB,Peek=MSG_PEEK,DontRoute=MSG_DONTROUTE};
|
||||
Socket(void);
|
||||
Socket(const Socket &someSocket);
|
||||
Socket(SOCKET someSOCKET);
|
||||
virtual ~Socket();
|
||||
Socket &operator=(const Socket &someSocket);
|
||||
Socket &operator=(SOCKET someSOCKET);
|
||||
bool operator==(const Socket &someSocket)const;
|
||||
operator SOCKET&(void);
|
||||
bool create(Domain domain=DomainInternet,Type type=SocketStream,Protocol protocol=ProtocolIPTCP);
|
||||
void destroy(void);
|
||||
bool connect(INETSocketAddress &internetSocketAddress);
|
||||
bool bind(INETSocketAddress &internetSocketAddress);
|
||||
bool bind(SocketAddress &socketAddress);
|
||||
bool listen(int maxPendingRequests=1);
|
||||
bool accept(Socket &someSocket);
|
||||
bool accept(Socket &someSocket,INETSocketAddress &internetSocketAddress);
|
||||
DWORD receive(char *buffer,DWORD count,bool waitForData=true);
|
||||
bool receive(char &charData,bool waitForData=true);
|
||||
bool receive(String &receiveString,bool waitForData=true);
|
||||
bool receive(Block<String> &receiveStrings);
|
||||
bool receiveFrom(void *pBuffer,int buflen,DWORD msgType,INETSocketAddress &from);
|
||||
bool receivePage(Block<String> &receiveStrings);
|
||||
bool receiveHeader(Block<String> &headerLines);
|
||||
bool receiveImage(String pathFileName,TimeInfo &someTimeInfo);
|
||||
bool receiveBinary(String pathFileName,DWORD sizeData,TimeInfo &someTimeInfo);
|
||||
bool receiveBinary(String pathFileName,TimeInfo &someTimeInfo);
|
||||
bool sendBinary(String pathFileName,TimeInfo &someTimeInfo);
|
||||
bool getSocketName(INETSocketAddress &internetSocketAddress);
|
||||
bool getPeerName(INETSocketAddress &internetSocketAddress);
|
||||
bool send(const char *buffer,DWORD count);
|
||||
bool send(const char &charData);
|
||||
bool send(const String &sendString);
|
||||
bool send(Block<String> &strings);
|
||||
bool sendTo(void *pBuffer,int buflen,INETSocketAddress &inetSocketAddress);
|
||||
bool hasData(void)const;
|
||||
bool isConnected(void)const;
|
||||
bool isBound(void)const;
|
||||
bool isListening(void)const;
|
||||
bool isInitialized(void)const;
|
||||
bool isOkay(void)const;
|
||||
SOCKET getSocket(void)const;
|
||||
bool reuseAddress(bool reuseAddress=true);
|
||||
bool setLinger(int seconds);
|
||||
bool setDontLinger(void);
|
||||
bool addMembership(IPMReq &ipMReq);
|
||||
bool dropMembership(IPMReq &ipMReq);
|
||||
bool setMulticastTTL(int ttl);
|
||||
bool setMulticastLoopback(bool loopback);
|
||||
private:
|
||||
enum Status{StatusConnect=0x0001,StatusBind=0x0002,StatusListen=0x0004};
|
||||
enum {MaxLength=32768,BlockLength=16384};
|
||||
bool canWrite(void)const;
|
||||
void isConnected(bool isConnected);
|
||||
void isBound(bool isBound);
|
||||
void isListening(bool isListening);
|
||||
|
||||
SOCKET mSocket;
|
||||
WORD mStatusBits;
|
||||
WSASystem mWSASystem;
|
||||
ReceiveCache mReceiveCache;
|
||||
Disposition mDisposition;
|
||||
};
|
||||
|
||||
inline
|
||||
Socket::Socket(void)
|
||||
: mSocket(INVALID_SOCKET), mDisposition(CloseSocket), mStatusBits(0L)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
Socket::Socket(const Socket &someSocket)
|
||||
{
|
||||
*this=someSocket;
|
||||
}
|
||||
|
||||
inline
|
||||
Socket::Socket(SOCKET someSOCKET)
|
||||
{
|
||||
*this=someSOCKET;
|
||||
}
|
||||
|
||||
inline
|
||||
Socket::~Socket()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
inline
|
||||
bool Socket::operator==(const Socket &someSocket)const
|
||||
{
|
||||
return mSocket==someSocket.mSocket;
|
||||
}
|
||||
|
||||
inline
|
||||
Socket::operator SOCKET&(void)
|
||||
{
|
||||
return mSocket;
|
||||
}
|
||||
|
||||
inline
|
||||
bool Socket::isOkay(void)const
|
||||
{
|
||||
return (INVALID_SOCKET==mSocket?false:true);
|
||||
}
|
||||
|
||||
inline
|
||||
bool Socket::canWrite(void)const
|
||||
{
|
||||
fd_set setDescriptor;
|
||||
|
||||
setDescriptor.fd_count=1;
|
||||
setDescriptor.fd_array[0]=mSocket;
|
||||
return ::select(0,0,&setDescriptor,0,0);
|
||||
}
|
||||
|
||||
inline
|
||||
bool Socket::hasData(void)const
|
||||
{
|
||||
fd_set setDescriptor;
|
||||
timeval waitTime;
|
||||
|
||||
setDescriptor.fd_count=1;
|
||||
setDescriptor.fd_array[0]=mSocket;
|
||||
waitTime.tv_sec=0;
|
||||
waitTime.tv_usec=0;
|
||||
return ::select(0,&setDescriptor,0,0,&waitTime);
|
||||
}
|
||||
|
||||
inline
|
||||
bool Socket::isInitialized(void)const
|
||||
{
|
||||
return mWSASystem.isInitialized();
|
||||
}
|
||||
|
||||
inline
|
||||
bool Socket::isConnected(void)const
|
||||
{
|
||||
return (mStatusBits&StatusConnect?true:false);
|
||||
}
|
||||
|
||||
inline
|
||||
void Socket::isConnected(bool isConnected)
|
||||
{
|
||||
if(isConnected)mStatusBits|=StatusConnect;
|
||||
else mStatusBits&=~StatusConnect;
|
||||
}
|
||||
|
||||
inline
|
||||
bool Socket::isBound(void)const
|
||||
{
|
||||
return (mStatusBits&StatusBind?true:false);
|
||||
}
|
||||
|
||||
inline
|
||||
void Socket::isBound(bool isBound)
|
||||
{
|
||||
if(isBound)mStatusBits|=StatusBind;
|
||||
else mStatusBits&=~StatusBind;
|
||||
}
|
||||
|
||||
inline
|
||||
bool Socket::isListening(void)const
|
||||
{
|
||||
return (mStatusBits&StatusListen?true:false);
|
||||
}
|
||||
|
||||
inline
|
||||
void Socket::isListening(bool isListening)
|
||||
{
|
||||
if(isListening)mStatusBits|=StatusListen;
|
||||
else mStatusBits&=~StatusListen;
|
||||
}
|
||||
|
||||
inline
|
||||
SOCKET Socket::getSocket(void)const
|
||||
{
|
||||
return mSocket;
|
||||
}
|
||||
#endif
|
||||
|
||||
BIN
socket/SOCKET.IDE
Normal file
BIN
socket/SOCKET.IDE
Normal file
Binary file not shown.
41
socket/SOCKET.PLG
Normal file
41
socket/SOCKET.PLG
Normal file
@@ -0,0 +1,41 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: socket - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\WINNT\Profiles\sean\LOCALS~1\Temp\RSP5D.tmp" with contents
|
||||
[
|
||||
/nologo /MTd /GX /Zi /Od /I "\work" /I "\parts" /D "_DEBUG" /D "__FLAT__" /D "STRICT" /D "WIN32" /D "_WINDOWS" /Fp"..\exe\msvc42.pch" /YX"windows.h" /Fo".\msvcobj/" /Fd".\msvcobj/" /FD /c
|
||||
"D:\work\socket\cache.cpp"
|
||||
"D:\work\socket\hooker.cpp"
|
||||
"D:\work\socket\Hostent.cpp"
|
||||
"D:\work\socket\Resolve.cpp"
|
||||
"D:\work\socket\Servent.cpp"
|
||||
"D:\work\socket\Socket.cpp"
|
||||
"D:\work\socket\Stdtmpl.cpp"
|
||||
"D:\work\socket\Wsadata.cpp"
|
||||
]
|
||||
Creating command line "cl.exe @C:\WINNT\Profiles\sean\LOCALS~1\Temp\RSP5D.tmp"
|
||||
Creating command line "link.exe -lib /nologo /out:"..\exe\mssocket.lib" .\msvcobj\cache.obj .\msvcobj\hooker.obj .\msvcobj\Hostent.obj .\msvcobj\Resolve.obj .\msvcobj\Servent.obj .\msvcobj\Socket.obj .\msvcobj\Stdtmpl.obj .\msvcobj\Wsadata.obj "
|
||||
<h3>Output Window</h3>
|
||||
Compiling...
|
||||
cache.cpp
|
||||
hooker.cpp
|
||||
Hostent.cpp
|
||||
Resolve.cpp
|
||||
Servent.cpp
|
||||
Socket.cpp
|
||||
Stdtmpl.cpp
|
||||
Wsadata.cpp
|
||||
Creating library...
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
mssocket.lib - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
13
socket/STDTMPL.CPP
Normal file
13
socket/STDTMPL.CPP
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef _MSC_VER
|
||||
#define _EXPAND_VECTOR_TEMPLATES_
|
||||
#define _EXPAND_BLOCK_TEMPLATES_
|
||||
#include <common/pvector.hpp>
|
||||
#include <common/pvector.tpp>
|
||||
#include <common/block.hpp>
|
||||
#include <common/block.tpp>
|
||||
#include <socket/inaddr.hpp>
|
||||
|
||||
typedef Block<InternetAddress> a;
|
||||
#endif
|
||||
|
||||
|
||||
424
socket/Socket.cpp
Normal file
424
socket/Socket.cpp
Normal file
@@ -0,0 +1,424 @@
|
||||
#include <socket/socket.hpp>
|
||||
#include <common/diskinfo.hpp>
|
||||
#include <common/openfile.hpp>
|
||||
#include <common/filemap.hpp>
|
||||
#include <common/pview.hpp>
|
||||
#include <common/profile.hpp>
|
||||
#include <common/block.hpp>
|
||||
|
||||
bool Socket::create(Domain domain,Type type,Protocol protocol)
|
||||
{
|
||||
destroy();
|
||||
if(!isInitialized())return isOkay();
|
||||
mSocket=::socket((int)domain,(int)type,(int)protocol);
|
||||
mReceiveCache.socket(mSocket);
|
||||
mDisposition=CloseSocket;
|
||||
return isOkay();
|
||||
}
|
||||
|
||||
void Socket::destroy(void)
|
||||
{
|
||||
if(!isOkay()||!isInitialized())return;
|
||||
if(CloseSocket==mDisposition)::closesocket(mSocket);
|
||||
mSocket=INVALID_SOCKET;
|
||||
isConnected(FALSE);
|
||||
isBound(FALSE);
|
||||
isListening(FALSE);
|
||||
}
|
||||
|
||||
Socket &Socket::operator=(const Socket &someSocket)
|
||||
{
|
||||
destroy();
|
||||
mSocket=someSocket.mSocket;
|
||||
mReceiveCache.socket(mSocket);
|
||||
mDisposition=AssumedSocket;
|
||||
isConnected(someSocket.isConnected());
|
||||
isBound(someSocket.isBound());
|
||||
isListening(someSocket.isListening());
|
||||
return *this;
|
||||
}
|
||||
|
||||
Socket &Socket::operator=(SOCKET someSOCKET)
|
||||
{
|
||||
destroy();
|
||||
mSocket=someSOCKET;
|
||||
mReceiveCache.socket(mSocket);
|
||||
mDisposition=CloseSocket;
|
||||
isConnected(FALSE);
|
||||
isBound(FALSE);
|
||||
isListening(FALSE);
|
||||
return *this;
|
||||
}
|
||||
|
||||
DWORD Socket::receive(char *buffer,DWORD count,bool waitForData)
|
||||
{
|
||||
DWORD cbytes(0);
|
||||
|
||||
for(;cbytes<count;cbytes++)
|
||||
{
|
||||
if(!mReceiveCache.receive(*buffer,waitForData))break;
|
||||
buffer++;
|
||||
}
|
||||
return cbytes;
|
||||
}
|
||||
|
||||
bool Socket::receive(char &charData,bool waitForData)
|
||||
{
|
||||
if(!isConnected())return false;
|
||||
if(!mReceiveCache.receive(charData,waitForData))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::receive(String &receiveString,bool waitForData)
|
||||
{
|
||||
char rcvChar;
|
||||
|
||||
receiveString.reserve(MaxLength);
|
||||
while(TRUE)
|
||||
{
|
||||
if(!isConnected())return false;
|
||||
if(!mReceiveCache.receive(rcvChar,waitForData))
|
||||
{
|
||||
if(receiveString.isNull())return false;
|
||||
break;
|
||||
}
|
||||
if(rcvChar==0x0D)continue;
|
||||
else if(rcvChar==0x0A)break;
|
||||
else receiveString+=rcvChar;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::receive(Block<String> &receiveStrings)
|
||||
{
|
||||
String stringData;
|
||||
String seriesItem;
|
||||
|
||||
receiveStrings.remove();
|
||||
while(TRUE)
|
||||
{
|
||||
if(!receive(stringData))break;
|
||||
if(!receiveStrings.size())seriesItem=stringData.substr(0,2);
|
||||
receiveStrings.insert(&stringData);
|
||||
if(!(stringData.operator[](3)=='-'&&stringData.substr(0,2)==seriesItem))break;
|
||||
if(!isConnected())break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::receiveFrom(void *pBuffer,int buflen,DWORD msgType,INETSocketAddress &from)
|
||||
{
|
||||
int fromLength(sizeof(sockaddr_in));
|
||||
if(!isOkay()||!pBuffer||buflen<=0)return false;
|
||||
return !(-1==::recvfrom(mSocket,(char*)pBuffer,buflen,msgType,(sockaddr*)&(from.getsockaddr()),&fromLength));
|
||||
}
|
||||
|
||||
bool Socket::receivePage(Block<String> &receiveStrings)
|
||||
{
|
||||
String stringData;
|
||||
|
||||
receiveStrings.remove();
|
||||
while(TRUE)
|
||||
{
|
||||
if(!receive(stringData))break;
|
||||
receiveStrings.insert(&stringData);
|
||||
if(stringData.substr(0,6)==String("</html>")||stringData.substr(0,6)==String("</HTML>"))break;
|
||||
else if(stringData.substr(0,13)==String("</body></html>")||stringData.substr(0,13)==String("</BODY></HTML>"))break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::receiveHeader(Block<String> &headerLines)
|
||||
{
|
||||
String stringData;
|
||||
|
||||
headerLines.remove();
|
||||
while(true)
|
||||
{
|
||||
if(!receive(stringData))break;
|
||||
if(stringData.isNull())break;
|
||||
stringData.lower();
|
||||
headerLines.insert(&stringData);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::receiveImage(String pathFileName,TimeInfo &someTimeInfo)
|
||||
{
|
||||
String strDirectory(pathFileName);
|
||||
DiskInfo diskInfo;
|
||||
Profile iniProfile;
|
||||
char rcvChar[BlockLength];
|
||||
DWORD bufferLength;
|
||||
DWORD receiveCount(0);
|
||||
Block<String> headerLines;
|
||||
DWORD sizeData(0);
|
||||
|
||||
if(!isConnected())return false;
|
||||
if(diskInfo.getDiskFreeSpace()<sizeData)return false;
|
||||
if(pathFileName.isNull())return false;
|
||||
if(iniProfile.makeDirectoryName(strDirectory))diskInfo.createDirectory(strDirectory);
|
||||
receiveHeader(headerLines);
|
||||
for(int lineIndex=0;lineIndex<headerLines.size();lineIndex++)
|
||||
{
|
||||
String &headerLine=headerLines[lineIndex];
|
||||
if(headerLine.betweenString(0,':')==String("content-length"))sizeData=::atoi(headerLine.betweenString(':',0));
|
||||
}
|
||||
if(!sizeData)return receiveBinary(pathFileName,250000,someTimeInfo);
|
||||
FileHandle writeFile(pathFileName,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite);
|
||||
if(!writeFile.isOkay())return false;
|
||||
someTimeInfo.startTime();
|
||||
while(receiveCount<sizeData)
|
||||
{
|
||||
if(receiveCount+sizeof(rcvChar)>sizeData)bufferLength=sizeData-receiveCount;
|
||||
else bufferLength=sizeof(rcvChar);
|
||||
while(!mReceiveCache.isReady(FALSE));
|
||||
mReceiveCache.receive(rcvChar,bufferLength,bufferLength);
|
||||
if(!bufferLength)continue;
|
||||
writeFile.write((unsigned char*)rcvChar,bufferLength);
|
||||
receiveCount+=bufferLength;
|
||||
if(!isConnected())break;
|
||||
}
|
||||
someTimeInfo.endTime(sizeData);
|
||||
writeFile.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::receiveBinary(String pathFileName,DWORD sizeData,TimeInfo &someTimeInfo)
|
||||
{
|
||||
String strDirectory(pathFileName);
|
||||
DiskInfo diskInfo;
|
||||
Profile iniProfile;
|
||||
char rcvChar[BlockLength];
|
||||
DWORD bufferLength;
|
||||
DWORD receiveCount(0);
|
||||
|
||||
if(!isConnected())return false;
|
||||
if(diskInfo.getDiskFreeSpace()<sizeData)return false;
|
||||
if(pathFileName.isNull())return false;
|
||||
if(iniProfile.makeDirectoryName(strDirectory))diskInfo.createDirectory(strDirectory);
|
||||
FileHandle writeFile(pathFileName,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite);
|
||||
if(!writeFile.isOkay())return false;
|
||||
someTimeInfo.startTime();
|
||||
while(receiveCount<sizeData)
|
||||
{
|
||||
if(receiveCount+sizeof(rcvChar)>sizeData)bufferLength=sizeData-receiveCount;
|
||||
else bufferLength=sizeof(rcvChar);
|
||||
while(!mReceiveCache.isReady(FALSE));
|
||||
if(!mReceiveCache.receive(rcvChar,sizeof(rcvChar),bufferLength))break;
|
||||
writeFile.write((unsigned char*)rcvChar,bufferLength);
|
||||
receiveCount+=bufferLength;
|
||||
if(!isConnected())break;
|
||||
}
|
||||
someTimeInfo.endTime(sizeData);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Socket::receiveBinary(String pathFileName,TimeInfo &someTimeInfo)
|
||||
{
|
||||
Profile iniProfile;
|
||||
char rcvChar[BlockLength];
|
||||
DWORD bufferLength(sizeof(rcvChar));
|
||||
DWORD receiveCount(0);
|
||||
|
||||
if(!isConnected())return false;
|
||||
iniProfile.makeFileName(pathFileName);
|
||||
if(pathFileName.isNull())return false;
|
||||
FileHandle writeFile(pathFileName,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite);
|
||||
someTimeInfo.startTime();
|
||||
while(true)
|
||||
{
|
||||
while(!mReceiveCache.isReady(false));
|
||||
if(!mReceiveCache.receive(rcvChar,sizeof(rcvChar),bufferLength))break;
|
||||
writeFile.write((unsigned char*)rcvChar,bufferLength);
|
||||
receiveCount+=bufferLength;
|
||||
if(!isConnected())break;
|
||||
}
|
||||
someTimeInfo.endTime(receiveCount);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::send(const char *buffer,DWORD count)
|
||||
{
|
||||
if(!isConnected())return false;
|
||||
if(!count)return false;
|
||||
canWrite();
|
||||
if(SOCKET_ERROR==::send(mSocket,buffer,count,0))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::send(const char &charData)
|
||||
{
|
||||
if(!isConnected())return false;
|
||||
canWrite();
|
||||
if(SOCKET_ERROR==::send(mSocket,&((char&)charData),sizeof(charData),0))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::send(Block<String> &strings)
|
||||
{
|
||||
for(int index=0;index<strings.size();index++)
|
||||
{
|
||||
if(!send(strings[index]))return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::send(const String &sendString)
|
||||
{
|
||||
String strLineString;
|
||||
String crlf("\r\n");
|
||||
int strLength;
|
||||
|
||||
// if(!isConnected()||sendString.isNull())return false;
|
||||
if(!isConnected())return false;
|
||||
strLineString=sendString+crlf;
|
||||
strLength=strLineString.length();
|
||||
canWrite();
|
||||
if(::send(mSocket,(LPSTR)((String&)strLineString),strLength,0)<strLength)return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::sendBinary(String pathFileName,TimeInfo &someTimeInfo)
|
||||
{
|
||||
FileHandle sendFile(pathFileName,FileHandle::Read,FileHandle::ShareRead);
|
||||
FileMap sendMap(sendFile);
|
||||
PureViewOfFile sendView(sendMap);
|
||||
char sndChar[BlockLength];
|
||||
DWORD sndLength;
|
||||
|
||||
if(!sendFile.isOkay())return false;
|
||||
someTimeInfo.startTime();
|
||||
while(true)
|
||||
{
|
||||
sndLength=sendView.read(sndChar,sizeof(sndChar));
|
||||
if(!sndLength)break;
|
||||
canWrite();
|
||||
if(SOCKET_ERROR==::send(mSocket,sndChar,sndLength,0))break;
|
||||
if(!isConnected())break;
|
||||
}
|
||||
someTimeInfo.endTime(sendFile.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::sendTo(void *pBuffer,int buflen,INETSocketAddress &inetSocketAddress)
|
||||
{
|
||||
if(!isOkay()||!pBuffer||!buflen)return false;
|
||||
return ::sendto(mSocket,(const char*)pBuffer,buflen,0,(sockaddr*)&((sockaddr_in&)inetSocketAddress),sizeof(sockaddr_in))?true:false;
|
||||
}
|
||||
|
||||
bool Socket::bind(INETSocketAddress &internetSocketAddress)
|
||||
{
|
||||
int nameLength(sizeof(sockaddr_in));
|
||||
if(isConnected()||isBound())return false;
|
||||
if(!isOkay()&&!create())return false;
|
||||
if(!::bind(mSocket,(sockaddr*)&((sockaddr_in&)internetSocketAddress),sizeof(sockaddr)))isBound(true);
|
||||
if(isBound())::getsockname(mSocket,(sockaddr*)&((sockaddr_in&)internetSocketAddress),&nameLength);
|
||||
return isBound();
|
||||
}
|
||||
|
||||
bool Socket::bind(SocketAddress &socketAddress)
|
||||
{
|
||||
if(isConnected()||isBound())return false;
|
||||
if(!isOkay()&&!create())return false;
|
||||
if(!::bind(mSocket,(sockaddr*)&((sockaddr_in&)socketAddress),SocketAddress::length()))isBound(true);
|
||||
return isBound();
|
||||
}
|
||||
|
||||
bool Socket::connect(INETSocketAddress &internetSocketAddress)
|
||||
{
|
||||
if(isConnected())return false;
|
||||
if(!isOkay()&&!create())return false;
|
||||
if(!::connect(mSocket,(sockaddr*)&((sockaddr_in&)internetSocketAddress),sizeof(sockaddr_in)))isConnected(TRUE);
|
||||
return isConnected();
|
||||
}
|
||||
|
||||
bool Socket::getSocketName(INETSocketAddress &internetSocketAddress)
|
||||
{
|
||||
int length(sizeof(sockaddr_in));
|
||||
if(!isOkay())return false;
|
||||
if(SOCKET_ERROR==::getsockname(mSocket,(sockaddr*)&((sockaddr_in&)internetSocketAddress),&length))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::getPeerName(INETSocketAddress &internetSocketAddress)
|
||||
{
|
||||
int length(sizeof(sockaddr_in));
|
||||
|
||||
if(!isConnected())return false;
|
||||
if(SOCKET_ERROR==::getpeername(mSocket,(sockaddr*)&((sockaddr_in&)internetSocketAddress),&length))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Socket::listen(int maxPendingRequests)
|
||||
{
|
||||
if(!isOkay()||!isBound())return FALSE;
|
||||
if(!::listen(mSocket,maxPendingRequests))isListening(TRUE);
|
||||
return isListening();
|
||||
}
|
||||
|
||||
bool Socket::accept(Socket &someSocket)
|
||||
{
|
||||
someSocket.destroy();
|
||||
if(!isOkay()||!isListening())return FALSE;
|
||||
someSocket=::accept(mSocket,0,0);
|
||||
if(someSocket.isOkay())someSocket.isConnected(TRUE);
|
||||
return someSocket.isOkay();
|
||||
}
|
||||
|
||||
bool Socket::accept(Socket &someSocket,INETSocketAddress &internetSocketAddress)
|
||||
{
|
||||
int addressLength(sizeof(sockaddr_in));
|
||||
|
||||
someSocket.destroy();
|
||||
if(!isOkay()||!isListening())return FALSE;
|
||||
someSocket=::accept(mSocket,(sockaddr*)&internetSocketAddress,&addressLength);
|
||||
if(someSocket.isOkay())someSocket.isConnected(TRUE);
|
||||
return someSocket.isOkay();
|
||||
}
|
||||
|
||||
bool Socket::reuseAddress(bool reuseAddress)
|
||||
{
|
||||
int reuse(reuseAddress);
|
||||
if(!isOkay())return false;
|
||||
return !(::setsockopt(mSocket,SOL_SOCKET,SO_REUSEADDR,(char*)&reuse,sizeof(int)));
|
||||
}
|
||||
|
||||
bool Socket::setLinger(int seconds)
|
||||
{
|
||||
LINGER linger;
|
||||
if(!isOkay())return false;
|
||||
linger.l_onoff=1;
|
||||
linger.l_linger=seconds;
|
||||
return !(::setsockopt(mSocket,SOL_SOCKET,SO_DONTLINGER,(char*)&linger,sizeof(linger)));
|
||||
}
|
||||
|
||||
bool Socket::setDontLinger(void)
|
||||
{
|
||||
LINGER linger;
|
||||
if(!isOkay())return false;
|
||||
linger.l_onoff=0;
|
||||
linger.l_linger=0;
|
||||
return !(::setsockopt(mSocket,SOL_SOCKET,SO_DONTLINGER,(char*)&linger,sizeof(linger)));
|
||||
}
|
||||
|
||||
bool Socket::addMembership(IPMReq &ipMReq)
|
||||
{
|
||||
return !(::setsockopt(mSocket,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char*)&((ip_mreq&)ipMReq),IPMReq::length()));
|
||||
}
|
||||
|
||||
bool Socket::dropMembership(IPMReq &ipMReq)
|
||||
{
|
||||
return !(::setsockopt(mSocket,IPPROTO_IP,IP_DROP_MEMBERSHIP,(char*)&((ip_mreq&)ipMReq),IPMReq::length()));
|
||||
}
|
||||
|
||||
bool Socket::setMulticastTTL(int ttl)
|
||||
{
|
||||
return !(::setsockopt(mSocket,IPPROTO_IP,IP_MULTICAST_TTL,(char*)&ttl,sizeof(ttl)));
|
||||
}
|
||||
|
||||
bool Socket::setMulticastLoopback(bool loopback)
|
||||
{
|
||||
int loop(loopback);
|
||||
return !(::setsockopt(mSocket,IPPROTO_IP,IP_MULTICAST_LOOP,(char*)&loop,sizeof(loop)));
|
||||
}
|
||||
507
socket/Socket.mak
Normal file
507
socket/Socket.mak
Normal file
@@ -0,0 +1,507 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=socket - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to socket - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "socket - Win32 Release" && "$(CFG)" != "socket - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Socket.mak" CFG="socket - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "socket - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "socket - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "socket - Win32 Debug"
|
||||
CPP=cl.exe
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
ALL : "$(OUTDIR)\Socket.lib"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cache.obj"
|
||||
-@erase "$(INTDIR)\hooker.obj"
|
||||
-@erase "$(INTDIR)\Hostent.obj"
|
||||
-@erase "$(INTDIR)\Resolve.obj"
|
||||
-@erase "$(INTDIR)\Servent.obj"
|
||||
-@erase "$(INTDIR)\Socket.obj"
|
||||
-@erase "$(INTDIR)\Stdtmpl.obj"
|
||||
-@erase "$(INTDIR)\Wsadata.obj"
|
||||
-@erase "$(OUTDIR)\Socket.lib"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
|
||||
/Fp"$(INTDIR)/Socket.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.\.
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/Socket.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
LIB32_FLAGS=/nologo /out:"$(OUTDIR)/Socket.lib"
|
||||
LIB32_OBJS= \
|
||||
"$(INTDIR)\cache.obj" \
|
||||
"$(INTDIR)\hooker.obj" \
|
||||
"$(INTDIR)\Hostent.obj" \
|
||||
"$(INTDIR)\Resolve.obj" \
|
||||
"$(INTDIR)\Servent.obj" \
|
||||
"$(INTDIR)\Socket.obj" \
|
||||
"$(INTDIR)\Stdtmpl.obj" \
|
||||
"$(INTDIR)\Wsadata.obj"
|
||||
|
||||
"$(OUTDIR)\Socket.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
|
||||
$(LIB32) @<<
|
||||
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "msvcobj"
|
||||
# PROP Intermediate_Dir "msvcobj"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\msvcobj
|
||||
INTDIR=.\msvcobj
|
||||
|
||||
ALL : "..\exe\mssocket.lib"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cache.obj"
|
||||
-@erase "$(INTDIR)\hooker.obj"
|
||||
-@erase "$(INTDIR)\Hostent.obj"
|
||||
-@erase "$(INTDIR)\Resolve.obj"
|
||||
-@erase "$(INTDIR)\Servent.obj"
|
||||
-@erase "$(INTDIR)\Socket.obj"
|
||||
-@erase "$(INTDIR)\Stdtmpl.obj"
|
||||
-@erase "$(INTDIR)\Wsadata.obj"
|
||||
-@erase "..\exe\mssocket.lib"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /Zp1 /MTd /Z7 /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__FLAT__" /D "STRICT" /Fp"..\exe\msvc42.pch" /YX"windows.h" /c
|
||||
CPP_PROJ=/nologo /Zp1 /MTd /Z7 /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\
|
||||
"__FLAT__" /D "STRICT" /Fp"..\exe\msvc42.pch" /YX"windows.h" /Fo"$(INTDIR)/" /c\
|
||||
|
||||
CPP_OBJS=.\msvcobj/
|
||||
CPP_SBRS=.\.
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/Socket.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"..\exe\mssocket.lib"
|
||||
LIB32_FLAGS=/nologo /out:"..\exe\mssocket.lib"
|
||||
LIB32_OBJS= \
|
||||
"$(INTDIR)\cache.obj" \
|
||||
"$(INTDIR)\hooker.obj" \
|
||||
"$(INTDIR)\Hostent.obj" \
|
||||
"$(INTDIR)\Resolve.obj" \
|
||||
"$(INTDIR)\Servent.obj" \
|
||||
"$(INTDIR)\Socket.obj" \
|
||||
"$(INTDIR)\Stdtmpl.obj" \
|
||||
"$(INTDIR)\Wsadata.obj"
|
||||
|
||||
"..\exe\mssocket.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
|
||||
$(LIB32) @<<
|
||||
$(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Target
|
||||
|
||||
# Name "socket - Win32 Release"
|
||||
# Name "socket - Win32 Debug"
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Wsadata.cpp
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
DEP_CPP_WSADA=\
|
||||
{$(INCLUDE)}"\.\Wsadata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Wsadata.obj" : $(SOURCE) $(DEP_CPP_WSADA) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
DEP_CPP_WSADA=\
|
||||
{$(INCLUDE)}"\.\Wsadata.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Wsadata.obj" : $(SOURCE) $(DEP_CPP_WSADA) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Resolve.cpp
|
||||
DEP_CPP_RESOL=\
|
||||
{$(INCLUDE)}"\.\Resolve.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Resolve.obj" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Servent.cpp
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
DEP_CPP_SERVE=\
|
||||
{$(INCLUDE)}"\.\Servent.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Servent.obj" : $(SOURCE) $(DEP_CPP_SERVE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
DEP_CPP_SERVE=\
|
||||
{$(INCLUDE)}"\.\Servent.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Servent.obj" : $(SOURCE) $(DEP_CPP_SERVE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Socket.cpp
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
DEP_CPP_SOCKE=\
|
||||
{$(INCLUDE)}"\.\Cache.hpp"\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\.\Intsaddr.hpp"\
|
||||
{$(INCLUDE)}"\.\Socket.hpp"\
|
||||
{$(INCLUDE)}"\.\Timeinfo.hpp"\
|
||||
{$(INCLUDE)}"\.\Wsadata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\Diskinfo.hpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Filemap.hpp"\
|
||||
{$(INCLUDE)}"\Common\Filetime.hpp"\
|
||||
{$(INCLUDE)}"\Common\Finddata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Fixup.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.tpp"\
|
||||
{$(INCLUDE)}"\Common\Openfile.hpp"\
|
||||
{$(INCLUDE)}"\Common\overlap.hpp"\
|
||||
{$(INCLUDE)}"\Common\Profile.hpp"\
|
||||
{$(INCLUDE)}"\Common\Puredwrd.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.tpp"\
|
||||
{$(INCLUDE)}"\Common\Pview.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Systime.hpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Socket.obj" : $(SOURCE) $(DEP_CPP_SOCKE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
DEP_CPP_SOCKE=\
|
||||
{$(INCLUDE)}"\.\Cache.hpp"\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\.\Intsaddr.hpp"\
|
||||
{$(INCLUDE)}"\.\Socket.hpp"\
|
||||
{$(INCLUDE)}"\.\Timeinfo.hpp"\
|
||||
{$(INCLUDE)}"\.\Wsadata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\Diskinfo.hpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Filemap.hpp"\
|
||||
{$(INCLUDE)}"\Common\Filetime.hpp"\
|
||||
{$(INCLUDE)}"\Common\Finddata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Fixup.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.tpp"\
|
||||
{$(INCLUDE)}"\Common\Openfile.hpp"\
|
||||
{$(INCLUDE)}"\Common\overlap.hpp"\
|
||||
{$(INCLUDE)}"\Common\Profile.hpp"\
|
||||
{$(INCLUDE)}"\Common\Puredwrd.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.tpp"\
|
||||
{$(INCLUDE)}"\Common\Pview.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Systime.hpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Socket.obj" : $(SOURCE) $(DEP_CPP_SOCKE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Stdtmpl.cpp
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
DEP_CPP_STDTM=\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Fixup.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.tpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Stdtmpl.obj" : $(SOURCE) $(DEP_CPP_STDTM) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
DEP_CPP_STDTM=\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Fixup.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pvector.tpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Stdtmpl.obj" : $(SOURCE) $(DEP_CPP_STDTM) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Hostent.cpp
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
DEP_CPP_HOSTE=\
|
||||
{$(INCLUDE)}"\.\Hostent.hpp"\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Hostent.obj" : $(SOURCE) $(DEP_CPP_HOSTE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
DEP_CPP_HOSTE=\
|
||||
{$(INCLUDE)}"\.\Hostent.hpp"\
|
||||
{$(INCLUDE)}"\.\Inaddr.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\Hostent.obj" : $(SOURCE) $(DEP_CPP_HOSTE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cache.cpp
|
||||
DEP_CPP_CACHE=\
|
||||
{$(INCLUDE)}"\.\Cache.hpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.tpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\cache.obj" : $(SOURCE) $(DEP_CPP_CACHE) "$(INTDIR)"
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hooker.cpp
|
||||
DEP_CPP_HOOKE=\
|
||||
{$(INCLUDE)}"\.\hooker.hpp"\
|
||||
{$(INCLUDE)}"\.\procaddr.hpp"\
|
||||
{$(INCLUDE)}"\.\procaddr.tpp"\
|
||||
{$(INCLUDE)}"\Common\Block.hpp"\
|
||||
{$(INCLUDE)}"\Common\Block.tpp"\
|
||||
{$(INCLUDE)}"\common\callback.hpp"\
|
||||
{$(INCLUDE)}"\common\callback.tpp"\
|
||||
{$(INCLUDE)}"\common\cbdata.hpp"\
|
||||
{$(INCLUDE)}"\common\cbptr.hpp"\
|
||||
{$(INCLUDE)}"\common\codegen.hpp"\
|
||||
{$(INCLUDE)}"\Common\except.hpp"\
|
||||
{$(INCLUDE)}"\Common\Filemap.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.hpp"\
|
||||
{$(INCLUDE)}"\Common\Gdata.tpp"\
|
||||
{$(INCLUDE)}"\common\gdipoint.hpp"\
|
||||
{$(INCLUDE)}"\common\pcallbck.hpp"\
|
||||
{$(INCLUDE)}"\common\point.hpp"\
|
||||
{$(INCLUDE)}"\Common\Puredwrd.hpp"\
|
||||
{$(INCLUDE)}"\Common\Pview.hpp"\
|
||||
{$(INCLUDE)}"\common\rect.hpp"\
|
||||
{$(INCLUDE)}"\common\stdio.hpp"\
|
||||
{$(INCLUDE)}"\Common\Stdlib.hpp"\
|
||||
{$(INCLUDE)}"\Common\String.hpp"\
|
||||
{$(INCLUDE)}"\Common\Types.hpp"\
|
||||
{$(INCLUDE)}"\Common\Windows.hpp"\
|
||||
{$(INCLUDE)}"\common\windowsx.hpp"\
|
||||
{$(INCLUDE)}"\Common\Winsock.hpp"\
|
||||
|
||||
|
||||
"$(INTDIR)\hooker.obj" : $(SOURCE) $(DEP_CPP_HOOKE) "$(INTDIR)"
|
||||
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
################################################################################
|
||||
BIN
socket/TDW.TRW
Normal file
BIN
socket/TDW.TRW
Normal file
Binary file not shown.
79
socket/TIMEINFO.HPP
Normal file
79
socket/TIMEINFO.HPP
Normal file
@@ -0,0 +1,79 @@
|
||||
#ifndef _SOCKET_TIMEINFO_HPP_
|
||||
#define _SOCKET_TIMEINFO_HPP_
|
||||
#include <stdio.h>
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class TimeInfo
|
||||
{
|
||||
public:
|
||||
TimeInfo(void);
|
||||
TimeInfo(const TimeInfo &timeInfo);
|
||||
virtual ~TimeInfo();
|
||||
TimeInfo &operator=(const TimeInfo &someTimeInfo);
|
||||
void startTime(void);
|
||||
void endTime(DWORD byteCount);
|
||||
operator String(void)const;
|
||||
private:
|
||||
double mSecondsElapsed;
|
||||
double mBytesPerSecond;
|
||||
DWORD mBytesReceived;
|
||||
};
|
||||
|
||||
inline
|
||||
TimeInfo::TimeInfo(void)
|
||||
: mSecondsElapsed(0.00), mBytesPerSecond(0.00), mBytesReceived(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
TimeInfo::TimeInfo(const TimeInfo &someTimeInfo)
|
||||
{
|
||||
*this=someTimeInfo;
|
||||
}
|
||||
|
||||
inline
|
||||
TimeInfo::~TimeInfo()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
TimeInfo &TimeInfo::operator=(const TimeInfo &someTimeInfo)
|
||||
{
|
||||
mSecondsElapsed=someTimeInfo.mSecondsElapsed;
|
||||
mBytesPerSecond=someTimeInfo.mBytesPerSecond;
|
||||
mBytesReceived=someTimeInfo.mBytesReceived;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void TimeInfo::startTime(void)
|
||||
{
|
||||
mSecondsElapsed=(double)::GetTickCount();
|
||||
mBytesPerSecond=0;
|
||||
mBytesReceived=0;
|
||||
}
|
||||
|
||||
inline
|
||||
void TimeInfo::endTime(DWORD byteCount)
|
||||
{
|
||||
mBytesReceived=byteCount;
|
||||
mSecondsElapsed=(double)::GetTickCount()-mSecondsElapsed;
|
||||
mSecondsElapsed/=1000.00;
|
||||
if(0.00==mSecondsElapsed)mBytesPerSecond=byteCount;
|
||||
else mBytesPerSecond=(1.00/mSecondsElapsed)*(double)byteCount;
|
||||
}
|
||||
|
||||
inline
|
||||
TimeInfo::operator String(void)const
|
||||
{
|
||||
String stringValue;
|
||||
|
||||
::sprintf(stringValue,"%ld bytes transferred in %lf seconds. (%lf KBS)",mBytesReceived,mSecondsElapsed,mBytesPerSecond/1000.00);
|
||||
return stringValue;
|
||||
}
|
||||
#endif
|
||||
60
socket/WSADATA.CPP
Normal file
60
socket/WSADATA.CPP
Normal file
@@ -0,0 +1,60 @@
|
||||
#include <socket/wsadata.hpp>
|
||||
|
||||
WORD WSASystem::smIsInitialized;
|
||||
WORD WSASystem::smInstanceCount;
|
||||
WSADATA WSASystem::smWSAData;
|
||||
|
||||
WSASystem::WSASystem(void)
|
||||
{
|
||||
WORD wsaVersion(MAKEWORD(1,1));
|
||||
++smInstanceCount;
|
||||
if(1==smInstanceCount)
|
||||
{
|
||||
::memset(&smWSAData,0,sizeof(smWSAData));
|
||||
if(!(::WSAStartup(wsaVersion,&smWSAData)))smIsInitialized=TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
String WSASystem::getLastError(void)const
|
||||
{
|
||||
switch(::WSAGetLastError())
|
||||
{
|
||||
case WSANOTINITIALISED :
|
||||
return "WSANOTINITIALISED : A successful WSAStartup must occur before using this function.";
|
||||
case WSAENETDOWN :
|
||||
return "WSAENETDOWN : The network subsystem has failed. ";
|
||||
case WSAEFAULT :
|
||||
return "WSAEFAULT : The buf or from parameters are not part of the user address space, or the fromlen parameter is too small to accommodate the peer address.";
|
||||
case WSAEINTR :
|
||||
return "WSAEINTR : The (blocking) call was canceled through WSACancelBlockingCall. ";
|
||||
case WSAEINPROGRESS :
|
||||
return "WSAEINPROGRESS : A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function. ";
|
||||
case WSAEINVAL :
|
||||
return "WSAEINVAL : The socket has not been bound with bind, or an unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled, or (for byte stream style sockets only) len was zero or negative. ";
|
||||
case WSAENETRESET :
|
||||
return "WSAENETRESET : The connection has been broken due to the remote host resetting.";
|
||||
case WSAENOTCONN :
|
||||
return "WSAENOTCONN : The socket is not connected (connection-oriented sockets only).";
|
||||
case WSAENOTSOCK :
|
||||
return "WSAENOTSOCK : The descriptor is not a socket.";
|
||||
case WSAEOPNOTSUPP :
|
||||
return "WSAEOPNOTSUPP : MSG_OOB was specified, but the socket is not stream style such as type SOCK_STREAM, out-of-band data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only send operations.";
|
||||
case WSAESHUTDOWN :
|
||||
return "WSAESHUTDOWN : The socket has been shut down; it is not possible to recvfrom on a socket after shutdown has been invoked with how set to SD_RECEIVE or SD_BOTH.";
|
||||
case WSAEWOULDBLOCK :
|
||||
return "WSAEWOULDBLOCK : The socket is marked as nonblocking and the recvfrom operation would block.";
|
||||
case WSAEMSGSIZE :
|
||||
return "WSAEMSGSIZE : The message was too large to fit into the specified buffer and was truncated.";
|
||||
case WSAECONNABORTED :
|
||||
return "WSAECONNABORTED : The virtual circuit was terminated due to a time-out or other failure. The application should close the socket as it is no longer usable.";
|
||||
case WSAETIMEDOUT :
|
||||
return "WSAETIMEDOUT : The connection has been dropped, because of a network failure or because the system on the other end went down without notice.";
|
||||
case WSAECONNRESET :
|
||||
return "The virtual circuit was reset by the remote side executing a <20>hard<72> or <20>abortive<76> close. The application should close the socket as it is no longer usable. On a UDP datagram socket this error would indicate that a previous send operation resulted in an ICMP \"Port Unreachable\" message.";
|
||||
case WSAEADDRINUSE :
|
||||
return "The specified address is already in use. (See the SO_REUSEADDR socket option under setsockopt.)";
|
||||
default :
|
||||
return "WSADATA.CPP: Unknown socket error";
|
||||
}
|
||||
}
|
||||
|
||||
106
socket/WSADATA.HPP
Normal file
106
socket/WSADATA.HPP
Normal file
@@ -0,0 +1,106 @@
|
||||
#ifndef _SOCKET_WSADATA_HPP_
|
||||
#define _SOCKET_WSADATA_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINSOCK_HPP_
|
||||
#include <common/winsock.hpp>
|
||||
#endif
|
||||
|
||||
class WSASystem
|
||||
{
|
||||
public:
|
||||
WSASystem(void);
|
||||
WSASystem(const WSASystem &someWSASystem);
|
||||
WSASystem &operator=(const WSASystem &someWSASystem);
|
||||
WORD operator==(const WSASystem &someWSASystem);
|
||||
virtual ~WSASystem();
|
||||
operator WSAData&(void);
|
||||
WORD versionLow(void)const;
|
||||
WORD versionHigh(void)const;
|
||||
String description(void)const;
|
||||
String systemStatus(void)const;
|
||||
WORD maxSockets(void)const;
|
||||
WORD isInitialized(void)const;
|
||||
BOOL cancelBlockingCall(void)const;
|
||||
BOOL isBlocking(void)const;
|
||||
String getLastError(void)const;
|
||||
private:
|
||||
static WORD smIsInitialized;
|
||||
static WORD smInstanceCount;
|
||||
static WSADATA smWSAData;
|
||||
};
|
||||
|
||||
inline
|
||||
WSASystem::WSASystem(const WSASystem &someWSASystem)
|
||||
{
|
||||
*this=someWSASystem;
|
||||
}
|
||||
|
||||
inline
|
||||
WSASystem::~WSASystem()
|
||||
{
|
||||
--smInstanceCount;
|
||||
if(!smInstanceCount&&smIsInitialized){::WSACleanup();smIsInitialized=FALSE;}
|
||||
}
|
||||
|
||||
inline
|
||||
WSASystem &WSASystem::operator=(const WSASystem &/*someWSASystem*/)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WSASystem::operator WSAData&(void)
|
||||
{
|
||||
return smWSAData;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD WSASystem::isInitialized(void)const
|
||||
{
|
||||
return smIsInitialized;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD WSASystem::versionLow(void)const
|
||||
{
|
||||
return smWSAData.wVersion;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD WSASystem::versionHigh(void)const
|
||||
{
|
||||
return smWSAData.wHighVersion;
|
||||
}
|
||||
|
||||
inline
|
||||
String WSASystem::description(void)const
|
||||
{
|
||||
return smWSAData.szDescription;
|
||||
}
|
||||
|
||||
inline
|
||||
String WSASystem::systemStatus(void)const
|
||||
{
|
||||
return smWSAData.szSystemStatus;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD WSASystem::maxSockets(void)const
|
||||
{
|
||||
return smWSAData.iMaxSockets;
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL WSASystem::cancelBlockingCall(void)const
|
||||
{
|
||||
return !::WSACancelBlockingCall();
|
||||
}
|
||||
|
||||
inline
|
||||
BOOL WSASystem::isBlocking(void)const
|
||||
{
|
||||
return ::WSAIsBlocking();
|
||||
}
|
||||
#endif
|
||||
82
socket/ipmcast.hpp
Normal file
82
socket/ipmcast.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
#ifndef _SOCKET_IPMULTICAST_HPP_
|
||||
#define _SOCKET_IPMULTICAST_HPP_
|
||||
#ifndef _SOCKET_SOCKET_HPP_
|
||||
#include <socket/socket.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_INTERNETADDRESS_HPP_
|
||||
#include <socket/inaddr.hpp>
|
||||
#endif
|
||||
|
||||
class IPMReq : private ip_mreq
|
||||
{
|
||||
public:
|
||||
IPMReq();
|
||||
virtual ~IPMReq();
|
||||
operator ip_mreq &(void);
|
||||
InternetAddress multicastAddress(void)const;
|
||||
void multicastAddress(const InternetAddress &multicastAddress);
|
||||
InternetAddress localAddress(void)const;
|
||||
void localAddress(const InternetAddress &localAddress);
|
||||
static int length(void);
|
||||
String toString(void)const;
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
IPMReq::IPMReq()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
IPMReq::~IPMReq()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
IPMReq::operator ip_mreq &(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress IPMReq::multicastAddress(void)const
|
||||
{
|
||||
return InternetAddress(ip_mreq::imr_multiaddr);
|
||||
}
|
||||
|
||||
inline
|
||||
void IPMReq::multicastAddress(const InternetAddress &multicastAddress)
|
||||
{
|
||||
ip_mreq::imr_multiaddr.S_un.S_un_b.s_b1=multicastAddress.b1();
|
||||
ip_mreq::imr_multiaddr.S_un.S_un_b.s_b2=multicastAddress.b2();
|
||||
ip_mreq::imr_multiaddr.S_un.S_un_b.s_b3=multicastAddress.b3();
|
||||
ip_mreq::imr_multiaddr.S_un.S_un_b.s_b4=multicastAddress.b4();
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress IPMReq::localAddress(void)const
|
||||
{
|
||||
return InternetAddress(ip_mreq::imr_interface);
|
||||
}
|
||||
|
||||
inline
|
||||
void IPMReq::localAddress(const InternetAddress &localAddress)
|
||||
{
|
||||
ip_mreq::imr_interface.S_un.S_un_b.s_b1=localAddress.b1();
|
||||
ip_mreq::imr_interface.S_un.S_un_b.s_b2=localAddress.b2();
|
||||
ip_mreq::imr_interface.S_un.S_un_b.s_b3=localAddress.b3();
|
||||
ip_mreq::imr_interface.S_un.S_un_b.s_b4=localAddress.b4();
|
||||
}
|
||||
|
||||
inline
|
||||
String IPMReq::toString(void)const
|
||||
{
|
||||
return String("mcast:")+multicastAddress().toString()+String(", local:")+localAddress().toString();
|
||||
}
|
||||
|
||||
inline
|
||||
int IPMReq::length(void)
|
||||
{
|
||||
return sizeof(ip_mreq);
|
||||
}
|
||||
#endif
|
||||
105
socket/sockaddr.hpp
Normal file
105
socket/sockaddr.hpp
Normal file
@@ -0,0 +1,105 @@
|
||||
#ifndef _SOCKET_SOCKETADDRESS_HPP_
|
||||
#define _SOCKET_SOCKETADDRESS_HPP_
|
||||
#ifndef _COMMON_WINSOCK_HPP_
|
||||
#include <common/winsock.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_INTERNETADDRESS_HPP_
|
||||
#include <socket/inaddr.hpp>
|
||||
#endif
|
||||
|
||||
class SocketAddress : private sockaddr_in
|
||||
{
|
||||
public:
|
||||
SocketAddress();
|
||||
virtual ~SocketAddress();
|
||||
operator sockaddr_in&(void);
|
||||
short family(void)const;
|
||||
void family(short family);
|
||||
unsigned short port(void)const;
|
||||
void port(unsigned short port);
|
||||
InternetAddress internetAddress(void)const;
|
||||
void internetAddress(const InternetAddress &internetAddress);
|
||||
static int length(void);
|
||||
String toString(void)const;
|
||||
private:
|
||||
void setZero(void);
|
||||
};
|
||||
|
||||
inline
|
||||
SocketAddress::SocketAddress()
|
||||
{
|
||||
setZero();
|
||||
}
|
||||
|
||||
inline
|
||||
SocketAddress::~SocketAddress()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SocketAddress::operator sockaddr_in&(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
short SocketAddress::family(void)const
|
||||
{
|
||||
return sockaddr_in::sin_family;
|
||||
}
|
||||
|
||||
inline
|
||||
void SocketAddress::family(short family)
|
||||
{
|
||||
sockaddr_in::sin_family=family;
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned short SocketAddress::port(void)const
|
||||
{
|
||||
return sockaddr_in::sin_port;
|
||||
}
|
||||
|
||||
inline
|
||||
void SocketAddress::port(unsigned short port)
|
||||
{
|
||||
sockaddr_in::sin_port=port;
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress SocketAddress::internetAddress(void)const
|
||||
{
|
||||
return InternetAddress(sockaddr_in::sin_addr);
|
||||
}
|
||||
|
||||
inline
|
||||
void SocketAddress::internetAddress(const InternetAddress &internetAddress)
|
||||
{
|
||||
sockaddr_in::sin_addr.S_un.S_un_b.s_b1=internetAddress.b1();
|
||||
sockaddr_in::sin_addr.S_un.S_un_b.s_b2=internetAddress.b2();
|
||||
sockaddr_in::sin_addr.S_un.S_un_b.s_b3=internetAddress.b3();
|
||||
sockaddr_in::sin_addr.S_un.S_un_b.s_b4=internetAddress.b4();
|
||||
}
|
||||
|
||||
inline
|
||||
void SocketAddress::setZero(void)
|
||||
{
|
||||
family(0);
|
||||
port(0);
|
||||
internetAddress(InternetAddress());
|
||||
}
|
||||
|
||||
inline
|
||||
String SocketAddress::toString(void)const
|
||||
{
|
||||
return internetAddress().toString()+String(":")+String().fromInt(port());
|
||||
}
|
||||
|
||||
inline
|
||||
int SocketAddress::length(void)
|
||||
{
|
||||
return sizeof(sockaddr_in);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
170
socket/socket.001
Normal file
170
socket/socket.001
Normal file
@@ -0,0 +1,170 @@
|
||||
# Microsoft Developer Studio Project File - Name="socket" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=socket - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "socket.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "socket.mak" CFG="socket - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "socket - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "socket - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\msvcobj"
|
||||
# PROP Intermediate_Dir ".\msvcobj"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /Zp1 /MTd /GX /Z7 /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__FLAT__" /D "STRICT" /Fp"..\exe\msvc42.pch" /YX"windows.h" /FD /c
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"..\exe\mssocket.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "socket - Win32 Release"
|
||||
# Name "socket - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cache.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hooker.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Hostent.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Resolve.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Servent.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Socket.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Stdtmpl.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Wsadata.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Cache.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hooker.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Hostent.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Inaddr.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Intsaddr.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\procaddr.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Resolve.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Servent.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Socket.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Timeinfo.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Wsadata.hpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\procaddr.tpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
176
socket/socket.dsp
Normal file
176
socket/socket.dsp
Normal file
@@ -0,0 +1,176 @@
|
||||
# Microsoft Developer Studio Project File - Name="socket" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=socket - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "socket.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "socket.mak" CFG="socket - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "socket - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "socket - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "socket - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /Gz /MT /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__FLAT__" /D "STRICT" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "socket - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\msvcobj"
|
||||
# PROP Intermediate_Dir ".\msvcobj"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /Gz /MTd /GX /Zi /Od /I "\work" /I "\parts" /D "_DEBUG" /D "__FLAT__" /D "STRICT" /D "WIN32" /D "_WINDOWS" /Fp"..\exe\msvc42.pch" /YX"windows.h" /FD /c
|
||||
# ADD BASE RSC /l 0x409
|
||||
# ADD RSC /l 0x409
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"..\exe\mssocket.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "socket - Win32 Release"
|
||||
# Name "socket - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cache.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hooker.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Hostent.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Resolve.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Servent.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Socket.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Stdtmpl.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Wsadata.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Cache.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hooker.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Hostent.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Inaddr.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Intsaddr.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\procaddr.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Resolve.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Servent.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Socket.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Timeinfo.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Wsadata.hpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\procaddr.tpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
29
socket/socket.dsw
Normal file
29
socket/socket.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "socket"=.\socket.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
BIN
socket/socket.mdp
Normal file
BIN
socket/socket.mdp
Normal file
Binary file not shown.
BIN
socket/socket.opt
Normal file
BIN
socket/socket.opt
Normal file
Binary file not shown.
Reference in New Issue
Block a user