<Introduction / Contents>

Command Types (client to server)

Direct Connect uses TCP for client to server communication.
The following section describes the format of the Commands, Each field is denoted with < >.
The fields in the command are separated by a single space character (ASCII 32).
And each Command ends with a | (pipe). All Commands are case sensitive.

$Hello

Shortly after a new user, <nick> logs in, the server must send,

$Hello <nick>

This indicates <nick> has logged in. If the new user is an operator, the server must additionally send a $OpList command to all users (documented at $GetNickList).

Each client should add <nick> to its list of hub users and, if $OpList is also received, update its list of operators. The new client must reply:

$Version <version>

$GetNickList

To obtain a list of other users' nicks, the client may send,

$GetNickList

to which the server must reply,

$NickList <nick1>$$<nick2>$$<nick3>$$...
$OpList <op1>$$<op2>$$<op3>$$...

If a client receives a $OpList command listing its own nick, it should enable the "Redirect User" and "Kick" functions.

$MyINFO (Client to Server)

Shortly after logging in, the client must send,

$MyINFO $ALL <nick> <interest>$ $<speed>$<e-mail>$<sharesize>$

The max size of the description is chosen by the hub implementation. (see $ValidateNick in Client to Server Login)
NOTE: some hub implementations do not consider a client to be in a logged in state before it has sent a $MyINFO. this is the correct behaviour, and the NMDC hub is flawed in this respect.

The server must pass this message to all users of the hub, including the sender. The client is expected to send this again if the information changes. SX says that the last byte of the speed is selected from the ascii values of 1 for normal, 2 for away, 3 also for away, 4 for fileserver, 5 also for fileserver, 6 for fileserver away, 7 also for fileserver away, 8 for fireball, 9 also for fireball, 10 for fireball away, and 11 also for fireball away.

$GetINFO

To obtain detailed information about a specific user, the client may send,

$GetINFO <othernick> <nick>

The server must respond with exactly the $MyINFO command sent by <othernick> to the server. I don't know what to do if <othernick> has not sent a $MyINFO command (perhaps he would have never been listed in $GetNickList, in which case the command could be rejected). I don't know what to do if <othernick> doesn't exist.

$ConnectToMe

The client may send $ConnectToMe to cause a peer to initiate a peer-to-peer connection for the purpose of transfering data.

$ConnectToMe <remoteNick> <senderIp>:<senderPort>

The server sends this message unaltered to <remotenick>. <remotenick> must open a TCP connection to <senderIp>:<senderPort>.

$MultiConnectToMe

The client may send this instead of the $ConnectToMe to cause a peer on another hub to initiate a peer-to-peer connection for the purpose of transfering data. This is an extension for multiple hubs, which I'm not worried about yet.

$MultiConnectToMe <nick> <senderIp>:<senderPort> <linkedserverip>:<linkedserverport>

$RevConnectToMe

A passive client may send this to cause a peer to send a $ConnectToMe back.

$RevConnectToMe <nick> <remoteNick>

The server must send this message unmodified to <remoteNick>. If <remoteNick> is an active client, it must send a $ConnectToMe to <nick>. If not, it will reply with $RevConnectToMe. The clients will no longer connect to each other because they are both in passive mode.

$To

The client may send $To to send a private message to a peer.

$To: <othernick> From: <nick> $<<nick>> <message>

The server must pass the message unmodified to client <othernick> which must display the message to the user.

< >

The client may send < > to send a public chat message to all hub users.

<<nick>> <message>

The server must pass the message unmodified to all other clients including <nick>.

$Quit

The client may send $Quit to indicate to the hub and to all other users that it is disconnecting from the hub.

$Quit <nick>

The client must then close the socket. The server must send this message to all users when it is received from a client, or when a client connection is lost. Each client should remove <nick> from its list of hub users.

$OpForceMove

An op may send a $OpForceMove to cause a client to move to a different server.

$OpForceMove $Who:<victimNick>$Where:<newIp>$Msg:<reasonMsg>

On receiving this, the server must send to <victimNick>,

$ForceMove <newIp>
$To: <victimNick> From: <senderNick> $<<senderNick>> You are being re-directed to <newHub> because: <reasonMsg>

In addition to displaying the message, <victimNick> must disconnect from the server and connect to <newIp>. The server should not disconnect the client. I'm not sure if the client should send $Quit or if it should simply close the socket.

$Kick

Ops may send $Kick to cause the hub to disconnect a user.

$Kick <victimNick>

The server must disconnect <victimNick>. The user is notified with the $To command.

$Search - Active clients

Clients are either "active", indicating they are on the Internet and can receive data directly from peers, or "passive", in which case they can communicate only through the existing connection to the server. To perform a search, an active client can send,

$Search <clientip>:<clientport> <searchstring>
i.e. $Search 64.78.55.32:412 T?T?500000?1?madonna$ray

<searchstring> is made up of

<sizerestricted>?<isminimumsize>?<size>?<datatype>?<searchpattern>

The server must forward this message unmodified to all the other users. Every other user with one or more matching files must send one UDP packet to <clientip>:<clientport> for each match containing just the message,

$SR <nick> <searchresponse> <hubip>:<hubport>

<searchresponse> is made up of

<filenamewithpath><filesizeinbytes> <current openslots>/<allopenslots><hubname>

Note: When the client sends the $SR command to the server it adds <ClientsNick> to the end of <searchresponse>.

$Search - Passive clients

To search the network for files matching a search term, a passive client may send,

$Search Hub:<searchingNick> <searchstring>

The server must forward this message unmodified to all the other users. Every other user with one or more matching files must send to the server,

$SR <resultNick> <filepath><filesize> <freeslots>/<totalslots><hubname> (<hubhost>[:<hubport>])^E<searchingNick>

The server must pass the $SR message unmodified to <searchingNick>.

$MultiSearch

This is takes the same parameters as $Search (both active and passive) and behaves exactly as $Search, except the hub must additionally pass the search request to the other hubs in the cluster using the hub-to-hub $Search command.

$SR - Passive search result

Replies to passive search requests are sent through the server. Compare the $SR in Command Types (client to client).

$SR <replynick> <searchresponse><searchnick>

<searchresponse> is made up of

<filenamewithpath><filesizeinbytes> <current openslots>/<allopenslots><hubname> (<hubip>)
The search result should be forwarded to <searchnick>, but without the <searchnick> at the end.