'From Squeak3.5alpha of ''7 January 2003'' [latest update: #5169] on 23 January 2003 at 5:18:13 pm'! "Change Set: Socket-sendUDPData-enh-sk Date: 21 January 2003 Author: sk Adds methods to Socket for sending datagrams while avoiding unecessary copying of data."! !Socket methodsFor: 'datagrams' stamp: 'sk 1/23/2003 17:17'! sendUDPData: aStringOrByteArray count: bytesToSend toHost: hostAddress port: portNumber "Send a UDP packet containing the first bytesToSend bytes of the given data to the specified host/port." ^ self sendUDPData: aStringOrByteArray startingAt: 1 count: bytesToSend toHost: hostAddress port: portNumber! ! !Socket methodsFor: 'datagrams' stamp: 'sk 1/23/2003 17:16'! sendUDPData: aStringOrByteArray startingAt: startIndex count: bytesToSend toHost: hostAddress port: portNumber "Send a UDP packet containing bytesToSend bytes of the given data starting at startIndex to the specified host/port." | bytesSent count | bytesSent _ 0. [bytesSent < bytesToSend] whileTrue: [ (self waitForSendDoneUntil: (Socket deadlineSecs: 20)) ifFalse: [self error: 'send data timeout; data not sent']. count _ self primSocket: socketHandle sendUDPData: aStringOrByteArray toHost: hostAddress port: portNumber startIndex: startIndex + bytesSent count: bytesToSend - bytesSent. bytesSent _ bytesSent + count]. ^ bytesSent! ! !Socket methodsFor: 'datagrams' stamp: 'sk 1/23/2003 17:17'! sendUDPData: aStringOrByteArray toHost: hostAddress port: portNumber "Send a UDP packet containing the given data to the specified host/port." ^ self sendUDPData: aStringOrByteArray startingAt: 1 count: aStringOrByteArray size toHost: hostAddress port: portNumber! !