Mantis - Squeak
Viewing Issue Advanced Details
1637 Network minor always 08-10-05 19:32 12-10-05 21:09
KenCausey  
gokr  
normal  
acknowledged  
open  
none    
none  
0001637: [ENH] Socket-sendUDPData
stefan kersten <steve@k-hornz.de>:

"from the changeset's preamble:

Adds methods to Socket for sending datagrams while avoiding unecessary
copying of data.

<sk>


'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 <steve@k-hornz.de>

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! !"

Notes
(0002225)
KenCausey   
08-10-05 19:35   
"Lex Spoon" <lex@cc.gatech.edu>:

"This looks like a simple and very reasonable improvement.

There is no SUnit test.

It only affects UDP, so it should be safe to add."
(0003270)
gokr   
12-10-05 21:09   
I will look it over and probably integrate in next push to inbox in 3.9.