Jump to content

Little problem with IP-Socket communication


Recommended Posts

Im new in Autoit an also new in TCP communication.

I want do build a tool to get information about a GIFTCARD.

The communication should go over IP-Socket.

This is what i have:

2.3 Message Format

Transfer of Request and Response parameters happens using direct port

communication.

- parameters handled as key/value pairs

- key names are NOT case sensitive

- required format: key=value

- the key/value pairs may be submitted in unspecified order

- each key/value pair is ended by a newline ASCII character sequence

o for request parameters following delimiter characters are accepted: CR+LF (integer values 13 and 10, typically used by Microsoft

Windows) LF (integer value 10, typically used by Unix and Unix-like

systems)

o for response parameters following ASCII character sequence for

[Newline] is used CR+LF (integer values 13 and 10, typically used by Microsoft

Windows)

- after all parameters a EOF must be sent. (Unix EOF Character, integer value

4) This character must also be followed by a newline ASCII character

sequence (CR+LF or LF).

Note:

- All fields in the message must be submitted in ASCII format

- Unused fields are not required to be sent.

- See Chapter Input Validation for detailed required parameter format

"Get_Info"

CARD_ID=10 digits

TRANS_TYP=20 (Retrive card's balance information and configuration parameters independent of card state.

An this is what i have coded in Autoit but the server give me always Error 100

Error 100 = Unexpected system exceptions

So TCP Connection is ok but the server don't understand what i want.

;Client
Global $IP = "10.3.5.123"
Global $PORT = 4999
Global $Connect = -1, $Recv
; to test
$asc10 = chr("10")
$asc4 = chr("4")


TCPStartup()

$txt = "CARD_ID=4747335296"& $asc10 &"TRANS_TYPE=20" & $asc10 & $asc4

;for testing $txt
MsgBox(0,"Send TXT",$txt)

While $Connect = -1
    $Connect = TCPConnect($IP, $PORT)
WEnd

;TCPSend($PORT,$txt)
TCPSend($PORT,"CARD_ID=4747335296"& $asc10 &"TRANS_TYPE=20" & $asc10 & $asc4)

While $Recv = ''
    $Recv = TCPRecv($Connect, 100)
WEnd

MsgBox(0,"IP-Socket",$Recv)
 
TCPCloseSocket($Connect)
TCPShutdown()

I hope someone can help me.

Thx

Christian Fiesel

Link to comment
Share on other sites

  • 2 weeks later...

While $Connect = -1

$Connect = TCPConnect($IP, $PORT)

WEnd

;TCPSend($PORT,$txt)

TCPSend($PORT,"CARD_ID=4747335296"& $asc10 &"TRANS_TYPE=20" & $asc10 & $asc4)

The TCPSend requires an opened socket. You are sending to the port, but no the opened $Connect socket. <_<

From the help-file:

;Attempt to connect to SERVER at its IP and PORT 33891

;=======================================================

$ConnectedSocket = TCPConnect($szIPADDRESS,$nPORT)

......

; We should have data in $szData... lets attempt to send it through our connected socket.

TCPSend($ConnectedSocket,$szData)

`

Oh, and you say it's the server, but ur code says it's the client? :)

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...