last day (15 days later) » 

9:07 AM
hi
 
 
3 hours later…
11:57 AM
@Liad Hi
 
im trying to build this server-client exercise using sockets. there is something i dont understand, they wrote in the exercise:
"Upon execution, the client will try to connect to the specified server. After a successful connection the
client will print “Connected Successfully.\n” and wait for commands from its stdin"
now they gave us a cpp file for all the messages.
in it, there is this function:
/*
 * Description: Prints to the screen a message when the client establish
 * connection to the server
*/
void print_connection();
its implementation is:
void print_connection() {
    printf("Connected Successfully.\n");
}
doesn't it print it in stdout?
 
Yes, printf prints to stdout.
Which typically is a console on the screen.
 
yea so this confuses me , dont the client needs to print it on its socket?
client1 output, what does it mean? stdout?
 
12:16 PM
I don't know. But the socket is for communication with the server, I think, and the message that a connection was established is supposed to inform the user. So stdout makes sense for that.
 
alright i will go with it.
so if there is no errors, by the time im at the last line i have a connection to the given server ?
struct sockaddr_in client;
    struct hostent *server;
    string client_name, server_name;
    server = gethostbyname(argv[2]);
    memset(&client,0,sizeof(struct sockaddr_in));
    client.sin_family = server->h_addrtype;
    memcpy(&client,server->h_addr,server->h_length);
    unsigned short port = atoi(argv[3]);
    client.sin_port = htons(port);
    //creating the socket
    int s = socket(AF_INET,SOCK_STREAM,0);
    connect(s,(struct sockaddr*)&client,sizeof(client) );
    print_connection();
the usage is
whatsappClient clientName serverAddress serverPort
(address is IP)
 
Are you sure that socket and connect throw when they fail? If not, you should check the return values or errno, whatever is appropriate.
 
im doing all the checks at the end
it makes it easier for me to read it with out all the if(..!=0){...}
 
You should do that before printing that the connection is established.
But yeah, it's easier to get an overview of how everything works with the error checking (temporarily) removed.
 
alright
now i need to wait for commands from the user to send to the server
like create_group bla client1,client2
looks like the right tool ^^
 
12:37 PM
Probably. But that's outside my area of modest expertise.
 
well i just met this function , so its not in my expertise either :-)
 
 
1 hour later…
2:03 PM
@DanielFischer im trying to show that $|\cup_{i \in I\cup J} x_i \times \{i\}| = |\cup_{i \in I} x_i \times\{i\} \cup \cup_{i \in J} x_i \times \{i\}|$
when $I\cap J = \emptyset$
so i just defined $f$ between the sets that takes $(x,i )$ to $(x,i)$
so its injective and onto by def.
does the assumption $I\cap J= \emptyset$ is just for $f$ to be well defined?
i feel like im missing someting
 
Unless I'm overlooking something, that's not needed at all.
 
the exercise is to show $\sum_{i \in I\cup J} |X_i| =\sum_{i \in I} |X_i|+\sum_{i \in J} |X_i| $
when$I\cap J = \emptyset$
and $|A| + |B| = |A \times \{0\} \cup B \times \{1\}|$
 
@Liad In that, you need the disjointness of $I$ and $J$. (You can have equality if they are not disjoint if infinite cardinals are involved.)
 
LHS is
$|\cup_{i \in I\cup J} x_i \times \{i\}|$
RHS is
$|\cup_{i \in I} x_i \times \{i\} \times \{0\} \cup \cup_{i \in J} x_i \times \{i\}| \times \{1\}|$
now $|A\times\{0\} | = |A|$
so by what i wrote before, we finished, where do i need the disjointness?
i think i got it
 
2:19 PM
In that last RHS, for $i \in I \cap J$, we have $x_i \times \{i\} \times \{0\}$ and $x_i \times \{i\} \times \{1\}$.
So $x_i$ would be counted twice.
 
yea exactly
 
In the first equation you wrote, we had only $x_i \times \{i\}$ occurring in both unions, and then the union of these was taken, and then it doesn't matter whether $x_i \times \{i\}$ occurs only in one or in both.
 
got it now
thanks
 
 
2 hours later…
4:38 PM
they want us to find $\sum_{n \in \Bbb N} |\Bbb R \ ^ n | $
so i said its equal to $|\Bbb N| 2 \ ^ {\Bbb N}$
beause $|\Bbb R \ ^ n| = 2 \ ^ {\Bbb N} $ for all $n\ge 1$
i dont feel like its very formal
what do you think?
 
5:30 PM
Yes, it's not very formal. I guess $$\sum_{n \in \mathbb{N}} \lvert \mathbb{R}^n\rvert = 1 + \sum_{n \in \mathbb{N}\setminus \{0\}} 2^{\aleph_0} = 1 + \aleph_0 2^{\aleph_0} = 1 + 2^{\aleph_0} = 2^{\aleph_0}$$ is more formal. But maybe not all steps in that have already been proved in the course, so maybe you need to justify some.
 
 
2 hours later…
7:06 PM
i swear this is exactly what i wrote! @DanielFischer
 
7:19 PM
btw how do you write א0 ? i have this char in my keyboard because its from Hebrew
 
\aleph_0
 
cool
i dont get what is this fd_set
why do i need this?
its supposed to work with the select function from before
do you understands how to use it? i can't figure it out , i want to use it , im not sure if in the client's side or server's side, and how :/
this is the last one
 
7:40 PM
No idea. Seems like a good time to search on SO.
 
i will
 
8:09 PM
well the name of the site is great
 

last day (15 days later) »