now to believe that i search to what i want for more that 4 months i send the things that i confused about it and please i want a clear arrengement or new code that let me know what is the right i feel every day that i go to the wrong way more and more
when recently i read about JPcap i thought that all that i write may be wrong but also i have i problem in writing a complete code by using the JPcap
so please i write that code below and i know that it was not for compilation but i want u to see that what i confused in and that i am realy work hard
and i put a comment in the code and between them about the problems that i have
\\ this is the began of my server and any server that i have no problem with it, ok
public static void main(String[] args) throws IOException {
ServerSocket clientSocket = null;
boolean listening = true;
bindAddr = InetAddress.getByName("10.0.0.1");
try {
clientSocket = new ServerSocket(80, 1000, bindAddr);
System.out.println("-started listening to port 80.");
} catch (IOException e) {
System.err.println("Could not listen on port: 80.");
System.exit(1);
}
int port = 3804;
int portP = port;
while (listening) {
now my problem is with what below, is the place of the filtering method is while listening and before accepting the socket? how can i read the packets and check it (the checking procedure is that, i read the packet and extract the TTL value from it, then compare that value with a table that i save before if its equels i pass that packet else i drop that packet)
\*my problem began here, is the below right if i want to filter the incoming packets? how i check it before accept the unwanted packets*/
try {
in = new BufferedReader(new FileReader("one-line.txt"));
\* i also want to ask about the above, is that mean that the containt of the ("one-line.txt") is an information that the server will send to the client or an information that the server save about the client? */
} catch (FileNotFoundException e){}
ok now i want to ask if i write the above ( in = new BufferedReader(new FileReader("one-line.txt")); )
did i need to write the below(byte[] buf = new byte[256]; ) because i think that is for saving the client info., doesn't it?
byte[] buf = new byte[256]; Packet packet = new Packet(buf, buf.length); socket.receive(packet);\\was that save the packet as it is, with its header info.?
now i want to extract the TTL value how can i do that? was the below code right to do it?
TTL=byte[8]; \\ then i continue the procedure by comparing with the table
i think that i must use socket.send(packet); at the client is that right? to save the entire packet with its header and save it in the byte[] as one packet a time, is that right?
after all what above and if the packet was wanted i accept it by accepting the socket?or what?
new PublicServerThread(clientSocket.accept(), portP, bindAddr).start();
sooo thanks to any help
so thanks for the time u take to read my post
with regards
This post has been edited by sarah waleed: 08 April 2011 - 08:10 AM

New Topic/Question
Reply



MultiQuote




|