Classic ASP
Classic ASP
Move a Connection into Another Socket
See more Socket/SSL/TLS Examples
Demonstrates Socket.TakeConnection, which moves the active connection from one Socket into another. The receiving object first releases any connection it previously held.
Background. Unlike TakeSocket, TakeConnection does not add a member to a socket set. After success, the source socket holds no connection. This is useful for handing an accepted connection to a dedicated handler object.
Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
set listenSock = Server.CreateObject("Chilkat.Socket")
success = listenSock.BindAndListen(5000,25)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( listenSock.LastErrorText) & "</pre>"
Response.End
End If
set connectedSock = Server.CreateObject("Chilkat.Socket")
success = listenSock.AcceptNext(20000,connectedSock)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( listenSock.LastErrorText) & "</pre>"
Response.End
End If
' Move the active connection out of connectedSock and into another Socket object. Unlike
' TakeSocket, this does not add a member to a socket set. After success, connectedSock holds no
' connection.
set handlerSock = Server.CreateObject("Chilkat.Socket")
success = handlerSock.TakeConnection(connectedSock)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( handlerSock.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "Connection moved to the handler socket.") & "</pre>"
%>
</body>
</html>