checkpoint
This commit is contained in:
parent
2f20425be7
commit
ba56ecf910
@ -25,6 +25,13 @@ int main(int argc, char const *argv[])
|
||||
serv_addr.sin_family = AF_INET;
|
||||
serv_addr.sin_port = htons(PORT);
|
||||
|
||||
// Convert IPv4 and IPv6 addresses from text to binary form
|
||||
if (inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr) <= 0)
|
||||
{
|
||||
printf("\nInvalid address/ Address not supported \n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
|
||||
{
|
||||
printf("\nConnection Failed \n");
|
||||
|
@ -35,18 +35,20 @@ int main(int argc, char const *argv[])
|
||||
perror("bind failed");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("bind\n");
|
||||
if (listen(server_fd, 3) < 0)
|
||||
{
|
||||
perror("listen");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("listening\n");
|
||||
if ((new_socket = accept(server_fd, (struct sockaddr *)&address,
|
||||
(socklen_t *)&addrlen)) < 0)
|
||||
{
|
||||
perror("accept");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("accepted\n");
|
||||
int avatar_fd = open("assets/test.jpg", O_RDONLY);
|
||||
if (avatar_fd < 0)
|
||||
{
|
||||
|
BIN
package.jpg
BIN
package.jpg
Binary file not shown.
Loading…
Reference in New Issue
Block a user