sss.cclass aaa { public static void main(String s[]) { bbb a; System.out.println("Start"); a = new bbb(); System.out.println("Before xx"); a.xx(); System.out.println("After xx"); } } class bbb { public native void xx(); public bbb() { System.out.println("in bbb"); System.loadLibrary("sss"); } }
sss.def#include <windows.h> void *Java_bbb_xx_stub(void * p) { MessageBox(0,"Hi","Hi",0); return p; }
LIBRARY sss EXPORTS Java_bbb_xx_stub
sss.cimport java.io.*; import java.servlet.*; public class s extends Servlet { public void service(ServletRequest req,ServletResponse res) throws IOException { bbb a; res.setContentType("text/html"); res.writeHeaders(); PrintStream out =new PrintStream(res.getOutputStream()); out.println("Start"); a=new bbb(); out.println("Before xx"); a.xx(); out.println("After xx"); } } class bbb { public native void xx(); public bbb() { System.loadLibrary("sss"); } }
sss.def#include <windows.h> void *Java_bbb_xx_stub(void * p) { MessageBox(0,"Hi","Hi",0); return p; }
LIBRARY sss EXPORTS Java_bbb_xx_stub
sss.defclass aaa { public static void main(String s[]) { bbb a; System.out.println("Start"); a = new bbb(); System.out.println("Before xx"); a.xx(); System.out.println("After xx"); } } class bbb { public native void xx(); public bbb() { System.out.println("in bbb"); System.loadLibrary("sss"); } }
sss.cLIBRARY sss EXPORTS Java_bbb_xx_stub
#include <windows.h> struct o { unsigned char Ttl,Tos,Flags,OptionsSize,*OptionsData; }; struct { DWORD Address; unsigned long Status,RoundTripTime; unsigned short DataSize,Reserved; void *Data; struct o Options; } E; HANDLE hIP;WSADATA wsa;HANDLE hIcmp;DWORD *dwIPAddr;struct hostent *phostent; DWORD d;char aa[100];struct o I; HANDLE ( WINAPI *pIcmpCreateFile )( VOID ); BOOL ( WINAPI *pIcmpCloseHandle )( HANDLE ); DWORD (WINAPI *pIcmpSendEcho)(HANDLE,DWORD,LPVOID,WORD,LPVOID, LPVOID,DWORD,DWORD); void *Java_bbb_xx_stub(void * p) { hIcmp = LoadLibrary( "ICMP.DLL" ); WSAStartup( 0x0101, &wsa ); MessageBox(0,"In Java_bb_xx_stub","hi",0); phostent = gethostbyname( "www.microsoft.com"); dwIPAddr = (DWORD *)( *phostent->h_addr_list ); pIcmpCreateFile=GetProcAddress( hIcmp,"IcmpCreateFile"); pIcmpCloseHandle=GetProcAddress( hIcmp,"IcmpCloseHandle"); pIcmpSendEcho =GetProcAddress( hIcmp,"IcmpSendEcho" ); hIP = pIcmpCreateFile(); I.Ttl=6; pIcmpSendEcho(hIP,*dwIPAddr,0,0,&I,&E,sizeof(E),8000 ); d=E.Address; phostent = gethostbyaddr((char *)&d,4,PF_INET); sprintf(aa,"gethostbyaddr %p",phostent ); MessageBox(0,aa,aa,0); if ( phostent != 0 ) MessageBox(0,phostent->h_name,"hi",0); wsprintf(aa,"RTT: %dms, TTL: %d",E.RoundTripTime,E.Options.Ttl ); MessageBox(0,aa,"hi",0); pIcmpCloseHandle( hIP ); FreeLibrary( hIcmp ); WSACleanup(); return p; }
The files in the project will beimport java.io.*; import java.servlet.*; public class s extends Servlet { public void service(ServletRequest req,ServletResponse res) throws IOException { bbb a; res.setContentType("text/html"); res.writeHeaders(); PrintStream out =new PrintStream(res.getOutputStream()); out.println("Start"); a=new bbb(); a.xx(); out.println("Hop No...." + a.ctr + "<p>"); out.println("Computer... : " + a.str + "<p>"); } } class bbb { int ctr; String str; public native void xx(); bbb() { System.loadLibrary("sss"); } }
sss.c
#include <StubPreamble.h> #include <fcntl.h> #include <javaString.h> struct o { unsigned char Ttl,Tos,Flags,OptionsSize,*OptionsData; }; struct { DWORD Address; unsigned long Status,RoundTripTime; unsigned short DataSize,Reserved; void *Data; struct o Options; } E; HANDLE hIP;WSADATA wsa;HANDLE hIcmp;DWORD *dwIPAddr;struct hostent *phostent; DWORD d;char aa[100],bb[100];struct o I; HANDLE ( WINAPI *pIcmpCreateFile )( VOID ); BOOL ( WINAPI *pIcmpCloseHandle )( HANDLE ); DWORD (WINAPI *pIcmpSendEcho)(HANDLE,DWORD,LPVOID,WORD,LPVOID, LPVOID,DWORD,DWORD); struct zzz { long f; struct Hjava_lang_String * p; }; struct yyy { struct zzz * oo; void * m; }; long bbb_xx(struct yyy * t) { char u[1000]; hIcmp = LoadLibrary( "ICMP.DLL" ); WSAStartup( 0x0101, &wsa ); phostent = gethostbyname( "www.microsoft.com"); dwIPAddr = (DWORD *)( *phostent->h_addr_list ); pIcmpCreateFile=GetProcAddress( hIcmp,"IcmpCreateFile"); pIcmpCloseHandle=GetProcAddress( hIcmp,"IcmpCloseHandle"); pIcmpSendEcho =GetProcAddress( hIcmp,"IcmpSendEcho" ); hIP = pIcmpCreateFile(); I.Ttl=6; pIcmpSendEcho(hIP,*dwIPAddr,0,0,&I,&E,sizeof(E),8000 ); d=E.Address; phostent = gethostbyaddr((char *)&d,4,PF_INET); sprintf(aa,"gethostbyaddr %p",phostent ); if ( phostent != 0 ) strcpy(aa,phostent->h_name); else strcpy(aa,"\0"); sprintf(bb,"...RTT: %dms, TTL: %d",E.RoundTripTime,E.Options.Ttl ); strcat(aa,bb); MessageBox(0,aa,"hi",0); pIcmpCloseHandle( hIP ); FreeLibrary( hIcmp ); WSACleanup(); strcpy(u,aa); t->oo->f = I.Ttl; t->oo->p=makeJavaString(u,strlen(u)); return 1; } stack_item * Java_bbb_xx_stub(stack_item * z, void *e) { bbb_xx(z->p); return z + 1; }
s.java<html> <form action=/servlet/s method=get> Host Computer:(www.neca.com) <br> <input type=text name=a><p> Hop Number :<br> <input type=text size=5 name=b><p> <input type=submit value="Click..."><p> </form> </html>
sss.cimport java.io.*; import java.servlet.*; public class s extends Servlet { int aa,bb; public void service(ServletRequest req,ServletResponse res) throws IOException { String aa = req.getQueryParameter("a"); String bb = req.getQueryParameter("b"); res.setContentType("text/html"); res.writeHeaders(); PrintStream out =new PrintStream(res.getOutputStream()); out.println("Computer... : " +aa+ "<p>"); out.println("Hop No...." + bb + "<p>"); bbb a; a=new bbb(); a.str1=aa; a.str2= bb; a.xx(); out.println("Result ..:" + a.str+ "<p>"); } } class bbb { String str,str1,str2; public native void xx(); bbb() { System.loadLibrary("sss"); } }
#include <StubPreamble.h> #include <fcntl.h> #include <javaString.h> struct o { unsigned char Ttl,Tos,Flags,OptionsSize,*OptionsData; }; struct { DWORD Address; unsigned long Status,RoundTripTime; unsigned short DataSize,Reserved; void *Data; struct o Options; } E; HANDLE hIP;WSADATA wsa;HANDLE hIcmp;DWORD *dwIPAddr;struct hostent *phostent; DWORD d;char aa[100],bb[100];struct o I; HANDLE ( WINAPI *pIcmpCreateFile )( VOID ); BOOL ( WINAPI *pIcmpCloseHandle )( HANDLE ); DWORD (WINAPI *pIcmpSendEcho)(HANDLE,DWORD,LPVOID,WORD,LPVOID, LPVOID,DWORD,DWORD); struct zzz { struct Hjava_lang_String * p; struct Hjava_lang_String * p1; struct Hjava_lang_String * p2; }; struct yyy { struct zzz * oo; void * m; }; long bbb_xx(struct yyy * t) { char u[1000],u1[1000],u2[1000]; int ii; javaString2CString(t->oo->p1,u1,1000); javaString2CString(t->oo->p2,u2,1000); ii=atoi(u2); MessageBox(0,u1,u2,0); hIcmp = LoadLibrary( "ICMP.DLL" ); WSAStartup( 0x0101, &wsa ); phostent = gethostbyname(u1); dwIPAddr = (DWORD *)( *phostent->h_addr_list ); pIcmpCreateFile=GetProcAddress( hIcmp,"IcmpCreateFile"); pIcmpCloseHandle=GetProcAddress( hIcmp,"IcmpCloseHandle"); pIcmpSendEcho =GetProcAddress( hIcmp,"IcmpSendEcho" ); hIP = pIcmpCreateFile(); I.Ttl=ii; pIcmpSendEcho(hIP,*dwIPAddr,0,0,&I,&E,sizeof(E),8000 ); d=E.Address; phostent = gethostbyaddr((char *)&d,4,PF_INET); sprintf(aa,"gethostbyaddr %p",phostent ); if ( phostent != 0 ) strcpy(aa,phostent->h_name); else strcpy(aa,"\0"); sprintf(bb,"...RTT: %dms, TTL: %d",E.RoundTripTime,E.Options.Ttl ); strcat(aa,bb); MessageBox(0,aa,"hi",0); pIcmpCloseHandle( hIP ); FreeLibrary( hIcmp ); WSACleanup(); strcpy(u,aa); t->oo->p=makeJavaString(u,strlen(u)); return 1; } stack_item * Java_bbb_xx_stub(stack_item * z, void *e) { bbb_xx(z->p); return z + 1; }
Mr. Vijay Mukhi
Ms. Sonal Kotecha
Move back to the Vijay Mukhi's Technology Cornucopia Page to learn more about the other new Internet Technologies.