@Don_Adan, post #3
@juen, post #4
@Krashan, post #5
@juen, post #8
test:
jsr bsdOpen
beq _error
move.l #$B952FA0E,d0 ;ip - (szajb.us) (32bit) - https://www.subnetonline.com/pages/converters/ip-to-bin-dec-and-bin-32-bit.php
move.w #1889,d1 ;port
jsr bsdConnect
bne _connectError
lea bsdMsg,a0
move.l #bsdMsgEnd-bsdMsg,d1
jsr bsdSend
lea bsdBuf,a0
move.l #bsdBufEnd-bsdBuf,d1
jsr bsdGet
_connectError:
jsr bsdClose
_error:
lea bsdBuf,a0
movem.l (a0)+,d0-d3 ;global error - d0 = 0, api error d0 = "ERR!", no error? d0 = "v1.0"
rts
even
bsdMsg: dc.b 'version abr'
bsdMsgEnd:
bsdBuf: dc.l 0,0,0,0
bsdBufEnd:
section bsdWrapper,code_p
; wrapper by juen
bsdGet: move.l bsdBase,a6
move.l bsdSocket,d0
moveq #0,d2
jsr -78(a6); recv()
bsdSend: move.l bsdBase,a6
move.l bsdSocket,d0
moveq #0,d2
jsr -66(a6); send()
rts
bsdConnect: move.l bsdBase,a6
lea bsdTarget,a0
move.w d1,2(a0)
move.l d0,4(a0)
move.l bsdSocket,d0
move.l #20,d1
jsr -54(a6); connect() -> 0 = ok!
tst.l d0
rts
bsdOpen: move.l 4,a6
lea bsdName,a1
moveq #0,d0
jsr -552(a6)
move.l d0,bsdbase
beq bsdError
move.l d0,a6
moveq #2,d0; AF_INET
moveq #1,d1; SOCK_STREAM (TCP)
moveq #0,d2; NOT USED IN TCP
jsr -30(a6); socket() -> -1 = fail
move.l d0,bsdSocket
move.l bsdBase,d0
rts
bsdClose: move.l bsdBase,a6
move.l bsdSocket,d0
jsr -120(a6); closeSocket()
move.l 4,a6
move.l bsdBase,a1
jsr -414(a6)
move.l #0,bsdBase
rts
bsdError: moveq #0,d0
rts
even
bsdBase: dc.l 0
bsdSocket: dc.l 0
bsdTarget: dc.w 2,0 ;AF_INET, PORT
dc.b 0,0,0,0 ;IP: 0.0.0.0
dc.b 0,0,0,0,0,0,0,0
bsdName: dc.b 'bsdsocket.library',0 @asman, post #14
test:
jsr bsdOpen
beq _error
move.l #$B952FA0E,d0 ;ip - (szajb.us) (32bit) - https://www.subnetonline.com/pages/converters/ip-to-bin-dec-and-bin-32-bit.php
move.w #1889,d1 ;port
jsr bsdConnect
bne _connectError
lea bsdMsg,a0
move.l #bsdMsgEnd-bsdMsg,d1
jsr bsdSend
lea bsdBuf,a0
move.l #bsdBufEnd-bsdBuf,d1
jsr bsdGet
_connectError:
jsr bsdClose
_error:
lea bsdBuf,a0
movem.l (a0)+,d0-d3 ;global error - d0 = 0, api error d0 = "ERR!", no error? d0 = "v1.0"
rts
even
bsdMsg: dc.b 'version abr'
bsdMsgEnd:
bsdBuf: dc.l 0,0,0,0
bsdBufEnd:
section bsdWrapper,code_p
; wrapper by juen
bsdGet: move.l bsdBase,a6
move.l bsdSocket,d0
moveq #0,d2
jsr -78(a6); recv()
bsdSend: move.l bsdBase,a6
move.l bsdSocket,d0
moveq #0,d2
jsr -66(a6); send()
rts
bsdConnect: move.l bsdBase,a6
lea bsdTarget,a0
move.w d1,2(a0)
move.l d0,4(a0)
move.l bsdSocket,d0
move.l #16,d1
jsr -54(a6); connect() -> 0 = ok!
tst.l d0
rts
bsdOpen: move.l 4,a6
lea bsdName,a1
moveq #0,d0
jsr -552(a6)
move.l d0,bsdBase
beq bsdError
move.l d0,a6
moveq #2,d0; AF_INET
moveq #1,d1; SOCK_STREAM (TCP)
moveq #0,d2; NOT USED IN TCP
jsr -30(a6); socket() -> -1 = fail
move.l d0,bsdSocket
move.l bsdBase,d0
rts
bsdClose: move.l bsdBase,a6
move.l bsdSocket,d0
jsr -120(a6); closeSocket()
move.l 4,a6
move.l bsdBase,a1
jsr -414(a6)
move.l #0,bsdBase
rts
bsdError: moveq #0,d0
rts
even
bsdBase: dc.l 0
bsdSocket: dc.l 0
bsdTarget: dc.w 2,0 ;AF_INET, PORT
dc.b 0,0,0,0 ;IP: 0.0.0.0
dc.b 0,0,0,0,0,0,0,0
bsdName: dc.b 'bsdsocket.library',0