here is part of my int main() {
Code:
struct sockaddr_in srcaddr; // client address - ( not really needed for this example )
struct sockaddr_in srcaddr2;
int srcaddrSize; // client address size - ( not really needed for this example )
FILE *output; // file to output to
long outputSize = 0; // to store the expected # bytes to receive from client
char buffer[BUFFER_SIZE]; // buffer to use for recving & writing
int bread = 0; // temp-var for bytes read from socket
int bwritten = 0; // temp-var for bytes written to file
int fd, fd2; // socket descriptor
printBanner();
fd = get_bound_udp_socket(SERVER_ADDR, SERVER_PORT); // Open socket for controls
fd2 = get_bound_udp_socket(SERVER_ADDR, SERVER_DPORT);
while (1) {
struct cmd_s *cmdrecieved;
char bufferd[BUFFER_SIZE];
recvfrom(fd, bufferd, BUFFER_SIZE, 0, (struct sockaddr *) & srcaddr, (socklen_t*) & srcaddrSize);
cmdrecieved = (struct cmd_s *) bufferd;
printf("Server recieved cmd: %s \n", cmdrecieved->cmd); // This works
//This is what I would like it to do
if (strncmp(cmdrecieved->cmd, "send", 3) == 0) {
printf("Function recieved: %s \n", cmdrecieved->cmd);
// Open up a socket on 7000 the dataport
//fd2 = get_bound_udp_socket(SERVER_ADDR, SERVER_DPORT); // Socket for controls
// Prepare command packet to be sent to the client.
// TODO: need Client Address
// we have port 12345, verified with Wireshark
// Lets assume 127.0.0.1 for now
// fprintf(stderr, "%s\n", inet_ntoa(srcaddr2.sin_addr));
prep_sockaddr_in(&srcaddr2, "127.0.0.1", CLIENT_PORT);
This might be enough to lend a hand for some suggestions.