Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-11

Re: Unit "Sockets"

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Rainer Stratmann

Hello,

does there exist a Demo Program for Unit Sockets?
I want to make a direct IPX connection between 2 Computers. And later an Internet connection.

Kind regards
Rainer

Reply by email

Daniël Mantione
to Rainer Stratmann: Linux OS. Where exactly can it be found? Because it seems the easiest way to port a DOS…

Op Thu, 16 Nov 2006, schreef Rainer Stratmann:

Show quoted text 18 lines
Am Donnerstag, 16. November 2006 10:58 schrieb Marco van de Voort: > > does there exist a Demo Program for Unit Sockets? > > I want to make a direct IPX connection between 2 Computers. > > And later an Internet connection. > > Which OS? Anyway, socket is mainly about TCP/IP, and there are demoes in > the description of the unit in the manual. Linux OS. Where exactly can it be found? > Why do you want to use IPX in this day and age? Because it seems the easiest way to port a DOS Program into Linux, because now I use also IPX in the DOS Program. IPX is a very low level, and if it woul be possible to send IPX packets without unit socket, it would also be good. May be later I would like to switch to an up to date protocol.

Below is some Linux IPX code I wrote once. In assembler. Perhaps it is of some use for you.

Daniël

%define IPX_NODE_LEN 6

%define IPX_USER_PTYPE 0
%define IPX_RIP_PTYPE 1
%define IPX_SAP_PTYPE 4

%define MSG_DONTWAIT $40

struc sockaddr_ipx
.family USHORT 1
.port USHORT 1
.network ULONG 1
.node UCHAR IPX_NODE_LEN
.type UCHAR 1
.zero UCHAR 1 ; to make structure 16 bytes long endstruc
[SECTION .data]

ipx_proc_file db '/proc/net/ipx',0

; Transport Tycoon uses IPX port $5115, but we should reverse the bytes ; because ports are specified in big endian

addr: istruc sockaddr_ipx
at sockaddr_ipx.family, dw AF_IPX
at sockaddr_ipx.port, dw $1551
at sockaddr_ipx.network, dd 0
at sockaddr_ipx.node, db 0,0,0,0,0,0
at sockaddr_ipx.type, db IPX_USER_PTYPE
at sockaddr_ipx.zero, db 0
iend

addr_size dd sockaddr_ipx_size

;
; Open an IPX socket. Original at $128207
; We open a socket and bind it to the right port.
;

open_ipx_socket:
sys_socket PF_IPX,SOCK_DGRAM,PF_IPX
_cmp eax,0
js .nosocket
push eax
sys_bind eax,addr,sockaddr_ipx_size
xchg ebx,eax
pop eax
mov word [$774fc],$333
or ebx,ebx
js .nosocket
clc
ret
.nosocket:
_mov ax,$0ffff
stc
ret

send_packet:
; eax,dx = IPX address to send packet to
; ebp = IPX network to send packet to
mov dword [addr+sockaddr_ipx.node],eax
mov word [addr+sockaddr_ipx.node+4],dx
mov dword [addr+sockaddr_ipx.network],ebp
call calc_checksum
mov [esi],ebx
mov ebx,$0ed08a
add ebx,[varedxxx_offset]
movzx eax,word [ebx]
_add ebx,2 ; Place $0ed08c in ebx
sys_sendto eax,ebx,64,0,addr,sockaddr_ipx_size
ret

receive_packet:
mov ebx,$0ed08a
add ebx,[varedxxx_offset]
movzx eax,word [ebx]
_add ebx,2 ; Place $0ed08c in ebx
sys_recvfrom eax,ebx,64,MSG_DONTWAIT,addr,addr_size _cmp eax,0
js .error
; Packet has been received
call calc_checksum
cmp [esi],ebx
jne .error
; Save the host we received the packet from.
mov esi,addr
mov edi,$0ed0d2
add edi,[varedxxx_offset]
mov eax,[esi+sockaddr_ipx.network]
mov [edi+10],eax
mov eax,[esi+sockaddr_ipx.node]
mov [edi],eax
mov ax,[esi+sockaddr_ipx.node+4]
mov [edi+4],ax
; Carry flag is already cleared by cmp [esi],ebx
ret
.error:
stc
ret

;
; Close the socket in ax.
;

close_ipx_socket:
cmp ax,-1
je .exit
cwde
sys_close eax
.exit:
ret

Reply by email

Rainer Stratmann
to Marco van de Voort: Which OS? Anyway, socket is mainly about TCP/IP, and there are demoes in the description…
Marco van de Voort wrote 6 lines
> does there exist a Demo Program for Unit Sockets? > I want to make a direct IPX connection between 2 Computers. > And later an Internet connection. Which OS? Anyway, socket is mainly about TCP/IP, and there are demoes in the description of the unit in the manual.

Linux OS.
Where exactly can it be found?

Why do you want to use IPX in this day and age?

Because it seems the easiest way to port a DOS Program into Linux, because now I use also IPX in the DOS Program.
IPX is a very low level, and if it woul be possible to send IPX packets without unit socket, it would also be good.
May be later I would like to switch to an up to date protocol.

_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email