All Manuals > LispWorks User Guide and Reference Manual > 32 The COMM Package

NextPrevUpTopContentsIndex

replace-socket-stream-socket

Function
Summary

Replaces the socket in a socket-stream, returning the existing socket object without closing it.

Package

comm

Signature

replace-socket-stream-socket socket-stream socket => socket-or-nil

Arguments

socket-stream

A socket-stream.

socket

A socket object or nil.

Values

socket-or-nil

A socket object or nil.

Description

The function replace-socket-stream-socket replaces the socket in the socket-stream socket-stream, returning the existing socket object without closing it.

A socket object is normally a socket in the native operating system sense (an integer representing an fd socket on Unix, and an integer representing SOCKET on Microsoft Windows), but when using the Java interface it can also be a Java socket (jobject of class java.net.Socket).

replace-socket-stream-socket sets the socket in socket-stream to the argument socket, and then returns the old socket object without closing it.

Notes
  1. Getting the old socket using the socket-stream accessor socket-stream-socket and then using (setf socket-stream-socket) to set the new one is different, because the cl:setf will close the old socket.
  2. Passing nil as the socket allows you to close the stream while retaining the socket.
  3. The new socket does not need to be the same kind of socket as the old one.
See also

socket-stream


LispWorks User Guide and Reference Manual - 13 Feb 2015

NextPrevUpTopContentsIndex