skreien Posted July 3, 2011 Posted July 3, 2011 Hey everyone, First, my apologies on the cross-post from the general help forum. I probably should have asked here first since I'm going down to the packet level. I'm trying to use the TCP capabilities of AutoIt to communicate with the Xymon monitoring software. Here's the order of operations that I MUST follow: SYN SYN ACK ACK send my client data now FIN ACK ACK server sends data back FIN ACK The server only sends its information back if it sees a FIN, ACK TCP sequence. I tried using TCPRecv after TCPSend, but that sends a RST, not a FIN, so it won't work. If I close the socket to generate the FIN ACK then try and reopen on the same port I never receive the data because the server is trying to reply on the now closed socket. I can send in reports fine, I just can't figure out how to receive the information coming back. Thanks for any help on this. I've been playing with various sequences for over a week and I'm stumped.
skreien Posted July 6, 2011 Author Posted July 6, 2011 (edited) Now that I'm back at work, here's the code I'm using. This is just a test file to try and get the idea working, but it's basically what I'm trying to do. expandcollapse popupLocal $XYMONHOST="10.170.1.200" Local $XYMONPORT="1984" Local $LOCALPORT Local $LOCALIPADDRESS Local $LOCALSOCKETSEND Local $LOCALSOCKETRECEIVE Local $LINETOSEND Local $LINERECEIVED Dim $TCPTABLE Local $ConnectedSocket = -1 Local $i Local $FILESIZE TCPStartup() $LOCALSOCKETSEND=TCPConnect($XYMONHOST,$XYMONPORT) if $LOCALSOCKETSEND=-1 Then ConsoleWrite("Socket not connected") Else $TCPTABLE=_GetTCPtable() For $i=1 to $TCPTABLE[0][0] if $TCPTABLE[$i][3]=$XYMONHOST and $TCPTABLE[$i][4]=$XYMONPORT Then $LOCALPORT=$TCPTABLE[$i][2] $LOCALIPADDRESS=$TCPTABLE[$i][1] ConsoleWrite("$LOCALIPADDRESS=" & $LOCALIPADDRESS & @CRLF) ConsoleWrite("$LOCALPORT=" & $LOCALPORT & @CRLF) ExitLoop EndIf Next $LINETOSEND="client test,hq.bbwin win32" TCPSend($LOCALSOCKETSEND,$LINETOSEND) ;TCPCloseSocket($LOCALSOCKETSEND) $LINERECEIVED=TCPRecv($LOCALSOCKETSEND,4096) ;$LOCALSOCKETRECEIVE=TCPListen($LOCALIPADDRESS,$LOCALPORT,100) ;Do ; $ConnectedSocket = TCPAccept($LOCALSOCKETSEND) ;Until $ConnectedSocket <> -1 ;$LINERECEIVED=TCPRecv($LOCALSOCKETRECEIVE,4096) EndIf ConsoleWrite("$LINERECEIVED=" & $LINERECEIVED & @CRLF) TCPShutdown() The problem is that this TCP sequence goes like this: SYN SYN ACK ACK send my client data now RST, ACK ACK RST a FIN is never sent, so the server never replies with its data. Edited July 6, 2011 by skreien
skreien Posted July 6, 2011 Author Posted July 6, 2011 OK, here is how it's done in powershell. Looks like they're reading the stream that comes back after socket shutdown. How can I do that with AutoIt? $socket.Client.Shutdown(1) # Signal to Xymon we're done writing. $s = new-object system.io.StreamReader($stream,"ASCII") start-sleep -m 200 # wait for data to buffer $outputBuffer = $s.ReadToEnd()
jvanegmond Posted July 14, 2011 Posted July 14, 2011 Here's the order of operations that I MUST follow:How did you figure this out?Everything about this sounds strange, so I'm going the obvious routes first -- as I'm sure you first have. Is there any Xymon remote documentation? What are you even working on (it's name)? github.com/jvanegmond
evilertoaster Posted July 15, 2011 Posted July 15, 2011 OK, here is how it's done in powershell. Looks like they're reading the stream that comes back after socket shutdown. How can I do that with AutoIt? $socket.Client.Shutdown(1) # Signal to Xymon we're done writing. That exact line would probably be something like: DllCall(DllOpen( "Ws2_32.dll" ), "int", "shutdown", "uint", $socket, "int", 1) ...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now