-// end Run
-
-void Client::InitiateServer() {
- if ( !isCompat( mSettings ) ) {
- int currLen;
- client_hdr* temp_hdr;
- if ( isUDP( mSettings ) ) {
- UDP_datagram *UDPhdr = (UDP_datagram *)mBuf;
- temp_hdr = (client_hdr*)(UDPhdr + 1);
- } else {
- temp_hdr = (client_hdr*)mBuf;
- }
- Settings_GenerateClientHdr( mSettings, temp_hdr );
- if ( !isUDP( mSettings ) ) {
- currLen = send( mSettings->mSock, mBuf, sizeof(client_hdr), 0 );
- if ( currLen < 0 ) {
- WARN_errno( currLen < 0, "write1" );
- }
- }
- }
+
+void Client::InitiateServer()
+{
+ client_hdr *temp_hdr = (client_hdr*)mBuf;
+
+ if (isCompat(mSettings))
+ return;
+ // connection-less protocols communicate their settings in the first
+ // packet sent to the server; this packet is not counted by the server
+ if (isConnectionLess(mSettings)) {
+ dgram_record *record_hdr = (dgram_record *)mBuf;
+ temp_hdr = (client_hdr*)(record_hdr + 1);
+ }
+
+ Settings_GenerateClientHdr( mSettings, temp_hdr );
+
+ // connection-oriented protocols use a short "init" message
+ if ( !isConnectionLess( mSettings ) ) {
+ int rc;
+
+ do {
+ rc = send(mSettings->mSock, mBuf, sizeof(client_hdr), 0);
+ } while (rc < 0 && errno == EAGAIN);
+ WARN_errno(rc < 0, "write failed in InitiateServer()");
+ }