I have a big problem and i hope you can help me! Iḿ trying to receive some Data from a Socket using the <sys/socket.h>.
The Function is:
buffer points to the buffer where the message should be stored.
ssize_t recvfrom(int socket, void *restrict buffer, size_t length,
int flags, struct sockaddr *restrict address,
socklen_t *restrict address_len)
First I declare The buffer with:
Then I try to receive it:
unsigned char p_buffer
After that all I print the data:
len = recvfrom(mysocket, p_buffer, 2048, 0, (struct sockad*)&p_info, &p_size);
Everything works really fine until now... .
unsigned char *p = p_buffer;
printf("%.2x ", *p);
I want to return the Data to a java program using the JNI
Chapter 5 Continued: Strings and Arrays
My return looks like this:
The Problem is, when I print the data from Java it looks like crap... .
return (*env)->NewStringUTF(env, *p);
Iḿ not really familiar with C and the data types.
The package is stored in a Char Array, unsigned char p_buffer, but when I print for example:
I get o.e. EF but.
printf("I AM: %x ", p_buffer)
I think I want to store this Hex elements in a new char array?!
I Hope somebody can help ! All this pointers and things are really confusing me !
Thanks and sorry for my bad English