hi,
im getting recv:bad address error in the server code when im receiving the data from the client.i tried passing the structure and an integer alone ,but for both i got the same error.
for structures:
client:
struct Data
{
char data1[255];
char data2[255];
int val1;
};
struct Data myData = { "Let us C", "YPK", 101 } ;
int ch = send(create_socket,&myData,sizeof(struct Data), 0);
struct Data
{
char data1[255];
char data2[255];
int val1;
};
void *dptr1;
struct Data *dptr;
struct Data *dptr = (struct Data*)(dptr1);
printf("The Elements of structure \n");
printf("Book- %s Author- %s Code- %d\n",dptr->data1,dptr->data2,dptr->val1);
for integer data:
client:
int a=5;
int ch = send(create_socket,&a,sizeof(int), 0);
server:
void *ptr;
int *iptr;
int ch=recv(new_socket,ptr,sizeof(int),0);
iptr = (int*)(ptr);
printf("Value of a is :%d\n",*iptr);