I'm doing a small client / server application for sharing files in C, and I am trying to implement the following:
The client of my application sends to the address 255.255.255.255 a message requesting a particular file.In the network there is only one server, however, there may be multiple clients.
The server responds with an ACK if it has the file specified by the client.Until now,everythings' allright.
The question arises now,as I want the client, after receiving the confirmation (ACK) from the server, making sure that the reply message comes from the server or if the message is of uknown origin.As so,I have the following code in Client:
The SERV_HOST_ADDR is set to "255.255.255.255" so the client can send the file request to the network and the port is also set with a value.Well, the problem arises when the call to the function recvfrom is made, where the ip address of who sent the message is filled in the structure.That address is ,thus, the address where the server is.
As so, when making the comparison between the SERV_HOST_ADDR in the if statement with the address serv_addr.sin_addr filled in the recvfrom call, they will never be the same (even if the reply has come from the server) ,as a it will always enter the else statement.
I would appreciate if someone could help me solve this problem, so that it would be a way the client could check you check whether the reply comes from the server where the client sent the message or from another place.
The last IP address in a network range is always considered unusable. It is, in fact, used for broadcast messages, meaning that (to my knowledge), you cannot create sockets with it. Also in the code above you have a space between the two ampersands. (& &). If that isn't just an artifact of copying the code into a webform, it's a bug.
hi there
so, i was given an assignment: implement a linux system call that blocks all packets that are sent to a given IP (i have to do it without using iptables)
i'm really new to kernel programming btw (and i'm enjoying it a lot)
so, my syscall is called ip_block() and receives a... (1 Reply)
Hi everyone,
I'm new to this forum. I'm working on new project for last few days and this forum already helped me on
couple of occasions. I don't have any prior experience with network programming so I'll appreciate any advise given.
I'm trying to do the following:
1. open user... (2 Replies)
in socket programming how can i : Create for example 3 blank files, namely: server, client, network
•Server: act as servers/provider, will receive all requests from different client
•Client: requesters
•Network: middle-layer of communication between server & client
any tips or... (6 Replies)
hi guys i got this code trying to make connection between the server and multi clients but when i do ./server i got message server waiting then when i run ./client it says client 1 nosuch file i dont know whats that should i use any argument plz help how to compile and run and whats the expected... (1 Reply)
Hi, i know how to use socket for TCP applications, i also know how to use RAW socket, but i would like to use socket just over IP and bellow TCP, do you know how to do that ?
i don't want to reimplement IP :)
thanks for your answer. (2 Replies)
Hi,
I am trying to connect to more than 60 servers to perform some actions remotely. for this I am using ssh2. But its taking lot of time.
Though i am running the command in background, still its taking long time to execute..
Any one let me know can we use sockets instead of ssh2 for... (3 Replies)
Hello,
I actually try to make client-server program.
I'm using SCO OpenServer Release 5.0.0 and when I try to compile my code (by TELNET) I've got this error :
I'm just using this simple code :
and I get the same error if I use :
If someone can help me,
Thanks (2 Replies)
Suppose i am writing a C program which is going to use Socket calls. I want to use a Unix port for my Socket.
How can i determine a port which is not already in use? (1 Reply)