Help Debugging
*#include <stdio.h> #include <stdlib.h> #include <winsock.h>
#define PORT 5842 #define IP "69.55.233.89"
int main(int argc, char *argv[]) { int a,b,c,d,x,sock; char answer[1024]; struct sockaddr_in s;
sock = socket(PF_INET, SOCK_STREAM, 0);
s.sin_family = AF_INET;
s.sin_port = htons(PORT);
s.sin_addr.s_addr = inet_addr(IP);
connect(sock, (struct sockaddr *) &s, sizeof(s));
recv(sock, &a, sizeof(unsigned int), 0);
recv(sock, &b, sizeof(unsigned int), 0);
recv(sock, &c, sizeof(unsigned int), 0);
recv(sock, &d, sizeof(unsigned int), 0);
printf("a = %d, b = %d, c = %d, d = %d\n", a, b, c, d);
x = a + b + c + d;
printf("Sum: %d\n", x);
send(sock, &x, sizeof(int), 0);
recv(sock, &answer, sizeof(answer), 0);
printf("s\n", answer);
system("PAUSE"); return 0; }*
anyone good with socket programming i need help debugging this program, i am getting the following error log:
main.c: In function main': main.c:24: warning: passing arg 2 of
recv' from incompatible pointer type
main.c:25: warning: passing arg 2 of recv' from incompatible pointer type main.c:26: warning: passing arg 2 of
recv' from incompatible pointer type
main.c:27: warning: passing arg 2 of recv' from incompatible pointer type main.c:35: warning: passing arg 2 of
send' from incompatible pointer type
main.c:37: warning: passing arg 2 of `recv' from incompatible pointer type
int recv(int fd, void *buf, int len, unsigned int flags);
Arguments:
fd -> is the socket descriptor to read from buf -> is the buffer to read the information into len -> is the maximum length of the buffer flags -> set it to 0
Note that the second argument is NOT supposed to be a pointer.
Here's just a simple example using recv()
{
n=recv(skt, buf, BUFFER_SIZE,0);
if (n<=0) break;
buf[n] = '\0';
cout << buf;
}```