dos与windows通过IPX通信的程序 (100分)

  • 主题发起人 主题发起人 lmwen2000
  • 开始时间 开始时间
L

lmwen2000

Unregistered / Unconfirmed
GUEST, unregistred user!
1.DOS 部分:
开发工具:Borland C++ 3.1
编译模式:Tiny 或 Large

IPX.ASM Large编译模式代码:

;-------Start--------
.model large
.data
public _ipxentry
_ipxentry dd 0

.code

public _reverseword
_reverseword:
push bp
mov bp,sp
mov ax,[bp+6]
xchg ah,al
pop bp
retf

public _ipxinit
_ipxinit:
push di
push es
mov ax,7A00h
int 2Fh
cmp al,0FFh
jnz _ipxinit0
mov word ptr [_ipxentry+0],di
mov word ptr [_ipxentry+2],es
_ipxinit0:
mov dx,word ptr [_ipxentry+2]
mov ax,word ptr [_ipxentry+0]
pop es
pop di
retf

public _ipxgetaddress
_ipxgetaddress:
push bp
mov bp,sp
mov bx,0009h
mov si,[bp+6]
mov es,[bp+8]
call [_ipxentry]
pop bp
retf

public _ipxgetmaxpacketsize
_ipxgetmaxpacketsize:
mov bx,001Ah
call [_ipxentry]
retf

public _ipxopensocket
_ipxopensocket:
push bp
mov bp,sp
push ds
mov al,[bp+6]
mov bx,[bp+8]
mov ds,[bp+10]
mov dx,[bx]
pop ds
mov bx,0000h
call [_ipxentry]
push ds
mov bx,[bp+8]
mov ds,[bp+10]
mov [bx],dx
mov ah,00h
pop ds
pop bp
retf

public _ipxclosesocket
_ipxclosesocket:
push bp
mov bp,sp
mov bx,0001h
mov dx,[bp+6]
call [_ipxentry]
pop bp
retf

public _ipxlistenforpacket
_ipxlistenforpacket:
push bp
mov bp,sp
push si
push es
mov bx,0004h
mov si,[bp+6]
mov es,[bp+8]
call [_ipxentry]
mov ah,00h
pop es
pop si
pop bp
retf

public _ipxsendpacket
_ipxsendpacket:
push bp
mov bp,sp
push si
push es
mov bx,0003h
mov si,[bp+6]
mov es,[bp+8]
call [_ipxentry]
pop es
pop si
pop bp
retf

public _ipxrelenquishcontrol
_ipxrelenquishcontrol:
mov bx,000Ah
call [_ipxentry]
retf

end
;---End---


clinet.c

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include "ipx.h"

IPXADDRESS myaddress;
IPXECB recb;
IPXHEADER rheader;
unsigned char rbuffer[80];
int i;

//------------------------------------------------------------------------------
void main ( void )
{
if(!ipxinit())
{
printf("IPX not installed/n");
exit(1);
}
myaddress.socket=reverseword(0x2000);
switch(ipxopensocket(0x00,&amp;myaddress.socket))
{
case 0x00: // Success
printf("Socket %04X/n",reverseword(myaddress.socket));
break;
case 0xFE:
printf("Socket Table Full/n");
exit(1);
case 0xFF:
printf("Socket Already Open/n");
exit(1);
}

recb.socket=myaddress.socket;
recb.esraddress=NULL;
recb.fragcount=2;
recb.fragaddr1=&amp;rheader;
recb.fragsize1=sizeof(IPXHEADER);
recb.fragaddr2=rbuffer;
recb.fragsize2=sizeof(rbuffer);
ipxlistenforpacket(&amp;recb);

printf("Waiting for packet/n");
while(!kbhit())
{
ipxrelenquishcontrol();
if(!recb.inuse)
{
printf("Packet Received/n");
printf(" from %02X:%02X:%02X:%02X %02X:%02X:%02X:%02X:%02X:%02X/n",rheader.source.netadd[0],rheader.source.netadd[1],rheader.source.netadd[2],rheader.source.netadd[3],rheader.source.nodeadd[0],rheader.source.nodeadd[1],rheader.source.nodeadd[2],rheader.source.nodeadd[3],rheader.source.nodeadd[4],rheader.source.nodeadd[5]);
printf(" from socket %04X/n",reverseword(rheader.source.socket));
break;
}
}
while(kbhit()) getch();
ipxclosesocket(myaddress.socket);
}


我想在DOS部分可以得到服务器端发过来的信息(username=user04 clear=0)应该如果改呢??
 
期待高手帮你解决,正在研究中...
 
要源码或例子。
源码不能给你。不过我可以告诉你,程序比较好写,只要你把交互协议定义好就行了
 
自己提前一下
 
后退
顶部