16,020,114 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Visual Basic questions
View Javascript questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by venkat28vk (Top 154 by date)
venkat28vk
30-May-17 7:38am
View
Yes i tried i have not found any link for converting from VB to C
venkat28vk
30-May-17 6:42am
View
@ cpallini. Can you kindly share me the link for converting from VB to C. I can also resolve the bugs after conversion.
venkat28vk
30-May-17 6:40am
View
@ Tadit Dash. Thanks for the quick response. I tried the link you have sent, but it shows only for vb to c# and vice versa. Not for VB to C.
I would like to have some tools for converting VB to C.
venkat28vk
28-Jan-16 1:23am
View
@Sergey. I have already developed code to send and receive files for single direction and also bi-direction. The real question is whether it is possible to select multiple files in a UI and send and receive it back.
venkat28vk
28-Dec-15 2:03am
View
@sergey. Will the code above code for work for reading a filename and its contents from client and send it to server, in the desired location in the server. If u find any errors, kindly guide me.
venkat28vk
28-Dec-15 0:26am
View
@ Garth. I am told to use only tcp/ip. It is because of that, i am using this protocol. Is there any ways to achieve the solution for the above with the code i have given. If so let me know.
venkat28vk
23-Dec-15 3:45am
View
@sergey. I am using Ubunutu. I need to display only file names. The files will be sent from php to C using tcp/ip, i need to display only the file names of html and text files. Can you give me some code on this.
venkat28vk
23-Dec-15 1:58am
View
@ Sergey. I am sorry for the above. The main objective is to list text files and html files in a folder using C code. How can i achieve the above?
venkat28vk
21-Dec-15 4:37am
View
I want to send data from client to server and the server has to reply back the same data. This should keep on iterating until i am terminating the process. How to achieve this in the above code
venkat28vk
19-Dec-15 5:41am
View
I like to send and receive data from client to server, and the server has to receive the data and send it back to client and moreover after this the client and the server has to be in open state(ready to transfer the data again)...this cycle should repeat. This is the scenario i want to achieve, how can i achieve it from my above code.
venkat28vk
15-Dec-15 0:14am
View
@Richard. Can i achieve it through command line arguments int main(int argc, char argv[]) or by using multiple threads as per you said.
venkat28vk
14-Dec-15 4:08am
View
@ richard. How can i read multiple files at concurrent time and send it to server in tcp/ip?
venkat28vk
14-Dec-15 0:35am
View
@ Giri. I am able to read a single text file using fopen and send it to the server. Now i need to try with multiple files.
venkat28vk
26-Nov-15 0:56am
View
No, i am told to use only in tcp/ip, is there any way for this?
venkat28vk
16-Oct-15 4:59am
View
I have changed with what u have said, but still i am not able to send and receive data.
venkat28vk
16-Oct-15 3:29am
View
@pallini. I need to read a file and send it to the client and the client has to send the same file back to server, this is the actual requirement. As far as i have done is just the connection is established, but not able to read and write data.
venkat28vk
16-Oct-15 2:34am
View
The connections are established, but the problem here is i am not able to send and receive the file.
venkat28vk
21-Sep-15 9:06am
View
I have used java code to create a UI and i have linked it with C code.
venkat28vk
21-Sep-15 9:05am
View
Deleted
i am giving the code for ref
#include "SingleDirectionCServer.h"
#include<jni.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys ioctl.h="">
#include<sys types.h="">
#include<arpa inet.h="">
#include<sys socket.h="">
//using namespace std;
//This function is to be used once we have confirmed that an video is to be sent
//It should read and output an video file
long long int receive_video(long long int socket,const char *file)
{
long long int buffersize = 0, recv_size = 0,size = 0, read_size, write_size;
char videoarray[10240],verify = '1',errno;
FILE *video;
//Find the size of the video
read(socket, &size, sizeof(int));
//Send our verification signal
write(socket, &verify,sizeof(char));
//Make sure that the size is bigger than 0
if(size <= 0 )
{
printf("Error has occurred. Size less than or equal to 0 \n");
return -1;
}
video = fopen(file, "w");
if( video == NULL)
{
printf("Error has occurred. video file could not be opened \n");
return -1;
}
//Loop while we have not received the entire file yet
while(recv_size < size)
{
ioctl(socket, FIONREAD, &buffersize);
//We check to see if there is data to be read from the socket
if(buffersize > 0 )
{
if(read_size = read(socket, videoarray, buffersize) < 0){
printf("%s", strerror(errno));
}
//Write the currently read data into our video file
write_size = fwrite(videoarray,1,(buffersize), video);
/* if(write_size != buffersize)
{
printf("write and buffer sizes are wrong \n");
}
if(read_size != write_size)
{
printf("error in read write \n");
} */
//Increment the total number of bytes read
recv_size += read_size;
//Send our handshake verification info
write(socket, &verify, sizeof(char));
}
}
fclose(video);
printf("video successfully Received! \n");
return 0;
}
JNIEXPORT jint JNICALL Java_SingleDirectionCServer_input
(JNIEnv *env, jobject obj, jint port, jstring file)
{
long long int socket_desc;
struct sockaddr_in server;
char *parray,errno;
const char *clocation = (*env)->GetStringUTFChars(env, file, NULL);
//Create socket
socket_desc = socket(AF_INET,SOCK_STREAM,0);
if (socket_desc == -1)
{
printf("Could not create socket \n");
}
memset(&server,0,sizeof(server));
server.sin_addr.s_addr = htonl(INADDR_ANY);
server.sin_family = AF_INET;
server.sin_port = htons(port);
//Connect to remote server
if (connect(socket_desc,(struct sockaddr *)&server , sizeof(server)))
{
// printf(strerror(errno));
//printf("Connect Error \n");
//return 1;
puts("Connected \n");
}
receive_video(socket_desc,clocation);
close(socket_desc);
//return 0;
}
venkat28vk
21-Sep-15 6:18am
View
Hi,
But when i am running C the code in my system, i am not facing any errors. How can i overcome this.
venkat28vk
21-Sep-15 6:18am
View
But when i run C program, i am able to send and receive files of any size. But when compared with java code in UI Creation, i am facing lot of issues.
venkat28vk
7-Sep-15 3:04am
View
I have just created a UI with send and exit button and in the send button code i have given one stmt on button click, also is there any way to compile the code before running it?
venkat28vk
7-Sep-15 2:19am
View
No such file or directory i am getting
venkat28vk
7-Sep-15 2:18am
View
Could you kindly assist me in developing Qt based application for C code because i am new to this and i need someone who has knowledge on the same.
venkat28vk
7-Sep-15 2:15am
View
I have just now tried to create a simple UI using Qt Creator, but i am facing some error in this. And one more doubt is Qt creator is enough or do i need any other packages. I am also getting an error stating that "error No such file or directory".
venkat28vk
7-Sep-15 1:49am
View
Can i use this to develop a UI for C program, because i have developed a set of codes in C and i need to develop a UI for various operations.
venkat28vk
20-Aug-15 4:31am
View
And moreover i am able to send a file to java in single directional way via tcp/ip with no data loss and java is able to receive it. I don't understand why when file is send from java to C, i am having data loss
venkat28vk
20-Aug-15 4:18am
View
I am able to receive a file from java to C via tcp/ip and send the same file back to java,i have given the same code but with slight change in function calling and it is working fine with no data loss or any other interruptions.
venkat28vk
20-Aug-15 3:18am
View
Are there any other ways to achieve it, because i have tried with all the options. Could you kindly say me how i can resolve this problem.
venkat28vk
18-Aug-15 8:16am
View
I have tried i am just sending a few characters, from java but in the receiving end i am getting like, what i have stated above.
venkat28vk
18-Aug-15 4:57am
View
And moreover is it really mandatory to use malloc, because i have commented it.
venkat28vk
18-Aug-15 4:53am
View
I have tried with pBuf in the recv function, but still i am getting the same output.
venkat28vk
18-Aug-15 4:33am
View
What can i give instead of pBuf to get my required output. And thanks for the answer provided on flag.
venkat28vk
18-Aug-15 3:33am
View
I tried as per you said but i am not getting the required output.And moreover in the above syntax i hope the buffer variable should be a pointer and is it really imp to give flag as 0 what if flag value is 1? Say your thoughts on this?
venkat28vk
18-Aug-15 3:13am
View
I have tried out with recv also, but still i am getting the same error. Just to state that i have tried with all options i have put the stmt in the code.
venkat28vk
18-Aug-15 2:52am
View
When i print the statements i am also getting the read size value as -1 in receive function, which indicates no data is written into the file.
venkat28vk
18-Aug-15 2:51am
View
I am receiving the file sent from java, but the values are displayed as following "
\00\00\00\00\00\00\00c@\00\00\00\00\009z\A2\FD\00\00\B3H\AA\84\00\00\00\94ބ\00\00 \00\00\00\00\00\00\00c@\00\00\00\00\00r\9F\A9\84"
venkat28vk
5-Aug-15 5:45am
View
Hi Frank, can you lend me help for the above problem, because i am facing lot of difficulties and i am able to receive text file with few characters and null data. Give me your valuable suggestions for this.
venkat28vk
29-Jul-15 9:07am
View
is all other part of code is correct, and do i need to change the file mode from w to a for saving the file.
venkat28vk
29-Jul-15 8:48am
View
I have tried read size equal to zero, but it is exiting out of the loop and no data are displayed. Could you kindly say me another possible way to resolve this.
venkat28vk
27-Jul-15 7:26am
View
Hi Frank,
I need your guidance for another time. This time it involves, C has to send a file to java and java has to accept the file and it should revert the same file to C. The fact is i am able to receive the file, but there is no data in it. Kindly assist me in resolving this issue.
I have given the code in the following link,
http://www.codeproject.com/Questions/1010219/How-To-Send-Data-From-C-To-Android-Using-Tcp-Ip-An?arn=0
venkat28vk
17-Jul-15 8:22am
View
Hi frank
I am able to send data to android, but when android is reading the data and sending the same data to C through TCP/IP, i am not able to receive it. I am giving the code for reference, just suggest some ideas.
Sending code:
int send_text( long int socket)
{
FILE *text;
char a[50];
long int size, read_size, stat, packet_index;
char send_buffer[1024], read_buffer[1024];
int wrt=0,sock_fd;
packet_index = 1;
int i=0;
text = fopen("/home/sosdt009/Desktop/character.txt", "r");
if (text == NULL)
{
printf("Error Opening text File");
exit(-1);
}
printf("Getting text Size\n");
fgets(a,2918992,text); //gets(a);
fseek(text, 0, SEEK_END);
size = ftell(text);
fseek(text, 0, SEEK_SET);
printf("Total text size: %li \n", size);
fgets(a,2918992,text); //gets(a); //
//Send text Size
printf("Sending text Size\n");
fgets(a,2918992,text); //gets(a);
send(socket, (void *)&size, sizeof(size), 0);
printf("Sending text as Byte Array\n");
fgets(a,2918992,text); //gets(a);
/*do
{
printf("Ready for sending:\n");
gets(a);
//Read while we get errors that are due to signals.
stat = recv(socket, read_buffer, 1024, 0);
printf("Bytes read: %li \n",stat);
gets(a);
}
while (stat < 0);
printf("Received data in socket:\n");
gets(a);
printf("Socket data: %s\n", read_buffer);
gets(a); */
while (EOF!=text)
{
//Read from the file into our send buffer
printf("Ready for sending \n");
read_size = fread(send_buffer,1,sizeof(send_buffer),text);
printf("The size of send buffer %c \n:", sizeof(send_buffer));
printf("The read size value is: %li \n", read_size);
fgets(a,2918992,text); //gets(a);
//Send data through our socket
do
{
printf(" Multiple loop \n");
//for(i=0;i<read_size;i++)
{
="" printf("send="" value:="" %c="" \n",send_buffer[i]);
="" }
="" stat="send(socket," send_buffer,="" read_size,="" 0);
="" printf("the="" send="" size="" value="" is:="" %li="" \n",="" size);
="" read="" read_size);
="" printf("="" multiple="" loop1="" \n");
="" }="" while="" (stat="" <=""
="" printf("packet="" %li,="" sent="" bytes.\n",="" packet_index,="" gets(a);
="" return="" -1;
="" packet_index++;
="" zero="" out="" our="" buffer
="" bzero(send_buffer,="" sizeof(send_buffer));
="" }
="" receive_text(socket);
="" fclose(text);
="" close(socket);
="" printf("text="" successfully="" send:="" \n");
="" fgets(a,2918992,text);="" 0;
}=""
receiving="" code:
int="" receive_text(int="" new_socket)
{
="" long="" int="" buffersize="0," recv_size="0," write_size;
="" errno;
="" file="" *text;
="" char="" str[50]="/home/sosdt009/Desktop/" ;
="" *pbuf,a[50],filename[50],*filename2;
="" ("enter="" filename:\n");
="" gets(filename);
="" printf("%s",filename);
="" strcat(str,filename);
="" filename2="fopen(str,"w");
" printf("filename2:\n");
="" gets(filename2);="" text="fopen(str,"w");
" if="" (text="=" null)
="" puts("error="" has="" occurred.="" could="" not="" be="" opened="" -1;
="" loop="" we="" have="" received="" the="" entire="" yet
="" (1)
="" {="" ioctl(new_socket,="" fionread,="" &buffersize);="" check="" to="" see="" there="" is="" data="" from="" socket
="" printf("buffersize="" ioctl="" %ld="" \n",buffersize);
="" gets(a);="" (buffersize=""> 0)
{
printf("Buffersize value is: %ld \n", buffersize);
gets(a);
pBuf = malloc(buffersize);
if (!pBuf)
{
fprintf(stderr, "Memory Error. Cannot allocate!\n");
gets(a);
exit(-1);
}
read_size = recv(new_socket, pBuf, buffersize, 0);
printf("Read size value is: %li \n", read_size);
gets(a);
if (read_size < 1)
{
printf("%s", strerror(errno));
gets(a);
goto free;
}
//Write the currently read data into our text file
write_size = fwrite(pBuf, 1, read_size, text);
free(pBuf);
printf("Writesize value is: %li \n", write_size);
gets(a);
//Increment the total number of bytes read
recv_size += read_size;
printf("Receivedsize value is: %li
venkat28vk
17-Jul-15 6:45am
View
Suggest me on this.
venkat28vk
16-Jul-15 8:15am
View
could you show me some sample code of it, for my better understanding.
venkat28vk
16-Jul-15 7:49am
View
The problem is after c sends the data, the code does not wait for java to send it keeps on iterating, once i stop the program manually(ctrl+c), i can see in java the number of bytes written or sent to C, but for that the socket has to be open, that is where i am facing the problem.
venkat28vk
13-Jul-15 6:13am
View
Just check for the code
venkat28vk
13-Jul-15 6:13am
View
int receive_text(int new_socket)
{
long int buffersize = 0, recv_size = 0, size = 0, read_size, write_size;
int errno;
FILE *text;
char *pBuf,a[50],filename[50],*filename2;
printf("Enter Filename:\n");
gets(filename);
printf("%s",filename);
strcat(str,filename);
filename2 = fopen(str,"w");
printf("Filename2:\n");
(filename2);
text = fopen(str,"w");
if (text == NULL)
{
puts("Error has occurred. Text file could not be opened \n");
gets(a);
return -1;
}
//Loop while we have not received the entire file yet
while (1)
{
ioctl(new_socket, FIONREAD, &buffersize);//We check to see if there is data to be read from the socket
printf("Buffersize ioctl value is %ld \n",buffersize);
gets(a);
if (buffersize > 0)
{
printf("Buffersize value is: %ld \n", buffersize);
gets(a);
pBuf = malloc(buffersize);
if (!pBuf)
{
fprintf(stderr, "Memory Error. Cannot allocate!\n");
gets(a);
exit(-1);
}
read_size = recv(new_socket, pBuf, buffersize, 0);
printf("Read size value is: %li \n", read_size);
gets(a);
if (read_size < 1)
{
printf("%s", strerror(errno));
gets(a);
goto free;
}
//Write the currently read data into our text file
write_size = fwrite(pBuf, 1, read_size, text);
free(pBuf);
printf("Writesize value is: %li \n", write_size);
gets(a);
//Increment the total number of bytes read
recv_size += read_size;
printf("Receivedsize value is: %li \n", recv_size);
gets(a);
}
if((buffersize == 0) && (recv_size != 0))
{
goto free;
}
}
free:
//close(new_socket);
fclose(text);
send_text(new_socket);
printf("Text successfully received: \n");
gets(a);
return 0;
}
The code has been put for further reference
venkat28vk
13-Jul-15 1:45am
View
I am receiving video file from Android to C using TCP/IP protocol. In the initial phases there were data loss when video file was sent, i rectified the error by giving gets() and now there is no data loss. How did gets() solved the error.
venkat28vk
9-Jul-15 7:35am
View
Deleted
Hi Frank,
I have to read a file which is sent from Android to C using TCP/IP, after the file is read, i have to write the same file to Android.
The problem is i am able to receive the data, but when i trying to send there is some logical error. Could you guide me through this.
I have given the code for reference
char str[50] = "/home/sosdt009/Desktop/";
int receive_text(int new_socket)
{
long int buffersize = 0, recv_size = 0, size = 0, read_size, write_size;
int errno;
FILE *text;
char *pBuf,a[50],filename[50],*filename2;
printf("Enter Filename:\n");
gets(filename);
printf("%s",filename);
strcat(str,filename);
filename2 = fopen(str,"w");
printf("Filename2:\n");
(filename2);
text = fopen(str,"w");
if (text == NULL)
{
puts("Error has occurred. Text file could not be opened \n");
gets(a);
return -1;
}
//Loop while we have not received the entire file yet
while (1)
{
ioctl(new_socket, FIONREAD, &buffersize);//We check to see if there is data to be read from the socket
printf("Buffersize ioctl value is %ld \n",buffersize);
gets(a);
if (buffersize > 0)
{
printf("Buffersize value is: %ld \n", buffersize);
gets(a);
pBuf = malloc(buffersize);
if (!pBuf)
{
fprintf(stderr, "Memory Error. Cannot allocate!\n");
gets(a);
exit(-1);
}
read_size = recv(new_socket, pBuf, buffersize, 0);
printf("Read size value is: %li \n", read_size);
gets(a);
if (read_size < 1)
{
printf("%s", strerror(errno));
gets(a);
goto free;
}
//Write the currently read data into our text file
write_size = fwrite(pBuf, 1, read_size, text);
free(pBuf);
printf("Writesize value is: %li \n", write_size);
gets(a);
//Increment the total number of bytes read
recv_size += read_size;
printf("Receivedsize value is: %li \n", recv_size);
gets(a);
}
if((buffersize == 0) && (recv_size != 0))
{
goto free;
}
}
free:
//close(new_socket);
fclose(text);
send_text(new_socket);
printf("Text successfully received: \n");
gets(a);
return 0;
}
int send_text( long int socket)
{
FILE *text;
char a[50];
long int size, read_size, stat, packet_index;
char send_buffer[1024], read_buffer[1024];
packet_index = 1;
text = fopen("/home/sosdt009/Desktop/sample.txt", "r");
if (text == NULL)
{
printf("Error Opening text File");
exit(-1);
}
printf("Getting text Size\n");
gets(a);
fseek(text, 0, SEEK_END);
size = ftell(text);
fseek(text, 0, SEEK_SET);
printf("Total text size: %li \n", size);
gets(a);
//Send text Size
printf("Sending text Size\n");
gets(a);
send(socket, (void *)&size, sizeof(size), 0);
printf("Sending text as Byte Array\n");
gets(a);
do
{
printf("Ready for sending:\n");
gets(a);
//Read while we get errors that are due to signals.
stat = recv(socket, read_buffer, 255, 0);
printf("Bytes read: %li \n",stat);
gets(a);
}
while (stat < 0);
printf("Received data in socket:\n");
gets(a);
printf("Socket data: %s\n", read_buffer);
gets(a);
return 0;
while (feof!=text)
{
//Read from the file into our send buffer
read_size = fread(socket, 1, sizeof(send_buffer), text);
printf("The read size value is: %li \n", read_size);
gets(a);
return -1;
//Send data through our socket
do
{
stat = send(socket, send_buffer, read_size, 0);
} while (stat < 0);
printf("Packet %li, sent %li bytes.\n", packet_index, read_size);
gets(a);
return -1;
packet_index++;
//Zero out our send buffer
bzero(send_buffer, sizeof(send_buffer));
}
close(socket);
fclose(text);
printf("Text successfully send: \n");
gets(a);
return 0;
}
I have given the receiving part and the sending part. To find out the error i have given printf stmts. In the send function after " Ready for sending" there is no action. what are the various causes of error.
venkat28vk
20-Jun-15 6:21am
View
Consider a scenario where client is sending n number of data and how can i accept all the files or i can add them in queue?
venkat28vk
10-Jun-15 4:41am
View
ok. Thanks a lot for helping me, through the way.
venkat28vk
10-Jun-15 0:29am
View
Hi Frank, still i am getting the same error as segmentation fault(core dumped)
venkat28vk
9-Jun-15 8:37am
View
void CleanInput(char *p)
{
int i;
char PATH_MAX;
for (i = 0; i < PATH_MAX; i++)
{
if (!p[i] || p[i] == '\n')
{
p[i] = '\0';
break;
}
}
}
int receive_text(int new_socket)
{
long int buffersize = 0, recv_size = 0, size = 0, read_size, write_size;
int errno;
FILE *text;
char *pBuf,*filename;
char a[50];
char PATH_MAX;
char Fullfilename[PATH_MAX];
FILE *fp;
printf("Enter Filename: %s \n",filename);
fgets(filename, PATH_MAX, fp); //Read filename from user
CleanInput(filename); //Remove \n and close string
//Build a full filename with path
char Filename[PATH_MAX];
strcpy(filename, "/home/sosdt009/Desktop/received.txt,r");
strcat( Fullfilename,Filename);
//Open file with fully qualified name and read the first line
fp=fopen(Fullfilename, "r");
char filename2[PATH_MAX];
fgets(filename2,PATH_MAX-1, fp);
fclose(fp);
CleanInput(Filename); //Remove \n and close string
//Print filename2, then open and read file2
printf("Filename2: %s \n", filename2);
fgets(filename2, PATH_MAX-1, fp);
CleanInput(Filename); //Remove \n and close string
text = fopen(filename2, "w");
if (text == NULL)
{
puts("Error has occurred. Text file could not be opened \n");
fgets(filename2, PATH_MAX-1, fp);
return -1;
}
//Loop while we have not received the entire file yet
while (1)
{
ioctl(new_socket, FIONREAD, &buffersize);//We check to see if there is data to be read from the socket
printf("Buffersize ioctl value is: %ld \n",buffersize);
fgets(filename, PATH_MAX, fp);
if (buffersize > 0)
{
printf("Buffersize value is: %ld \n", buffersize);
fgets(filename, PATH_MAX, fp);
pBuf = malloc(buffersize);
if (!pBuf)
{
fprintf(stderr, "Memory Error. Cannot allocate!\n");
fgets(filename, PATH_MAX, fp);
exit(-1);
}
read_size = recv(new_socket, pBuf, buffersize, 0);
printf("Read size value is: %li \n", read_size);
fgets(filename, PATH_MAX, fp);
if (read_size < 1)
{
printf("%s", strerror(errno));
fgets(filename, PATH_MAX, fp);
goto free;
}
//Write the currently read data into our text file
write_size = fwrite(pBuf, 1, read_size, text);
free(pBuf);
printf("Writesize value is: %li \n", write_size);
fgets(filename, PATH_MAX, fp);
//Increment the total number of bytes read
recv_size += read_size;
printf("Receivedsize value is: %li \n", recv_size);
fgets(filename, PATH_MAX, fp);
}
if((buffersize == 0) && (recv_size != 0))
{
goto free;
}
}
free:
close(new_socket);
fclose(text);
printf("Text successfully received: \n");
fgets(filename, PATH_MAX, fp);
return 0;
}
this is the entire source code, and when android is sending some data the connection is opened and after that enter file name and segmentation fault error is shown.
venkat28vk
9-Jun-15 7:36am
View
I am getting error, once the code is compiled.
Enter Filename:
Segmentation fault (core dumped)
venkat28vk
9-Jun-15 4:57am
View
Frank the reason for the error is i cant assign a file path to a character it has to be assigned to a file pointer and using fopen with specified mode.
venkat28vk
9-Jun-15 3:09am
View
I have given the code for reference
void CleanInput(char *p)
{
int i;
char MAX_PATH;
for(i=0;i<=(MAX_PATH);i++)
{
if (!p[i] || p[i]=='\n')
{
p[i] = '\0';
break;
}
}
}
int receive_text(int new_socket)
{
long int buffersize = 0, recv_size = 0, size = 0, read_size, write_size;
int errno;
FILE *text;
char *pBuf,*filename;
char a[50];
char PATH_MAX;
char Fullfilename[PATH_MAX];
FILE *fp;
printf("Enter Filename:\n");
fgets(Fullfilename, PATH_MAX, fp); //Read filename from user
CleanInput(Fullfilename); //Remove \n and close string
//Build a full filename with path
char Filename[PATH_MAX] = "/home/sosdt009/Desktop";
strcat( Fullfilename,Filename);
//Open file with fully qualified name and read the first line
fp=fopen(Fullfilename, "r");
char filename2[PATH_MAX];
fgets(filename2,PATH_MAX-1, fp);
fclose(fp);
CleanInput(Filename); //Remove \n and close string
//Print filename2, then open and read file2
printf("Filename2: %s \n", filename2);
fgets(filename2, PATH_MAX-1, fp);
CleanInput(Filename); //Remove \n and close string
text = fopen(filename2, "w");
venkat28vk
9-Jun-15 3:08am
View
still i am getting the same error
venkat28vk
9-Jun-15 3:00am
View
char Filename[MAX_PATH] = "/home/sosdt009/Desktop";
It is already like that only
venkat28vk
9-Jun-15 0:43am
View
error: variable-sized object may not be initialized
char Filename[MAX_PATH] = "/home/sosdt009/Desktop";
This is the only error i am getting.
venkat28vk
8-Jun-15 7:28am
View
I have resolved the first error by assigning a condition. Only the second error is left out.
venkat28vk
8-Jun-15 7:12am
View
can i have the source code you have given early , because the question for the above code is closed.
venkat28vk
8-Jun-15 5:55am
View
Hi Frank in the latest code i have posted
printf("Enter Filename:\n");
gets(filename);
filename2 = open("/home/sosdt009/Desktop", && filename);
printf("Filename2: %s \n", filename2);
gets(a);
text = fopen(filename2, "w");
I have edited all the changes as per you said, but there are two errors caused while running the program
1)error: expected expression before ‘)’ token
for(i=0; i<max_path>)
2) error: variable-sized object may not be initialized
char FullFilename[MAX_PATH] = "/home/sosdt009/Desktop";
i have tried by various means ,but i could not solve this.How to resolve this issue.
venkat28vk
6-Jun-15 2:25am
View
I will receive a file(ie text, audio)and store the file into a string and again the read the string and display it as output in another string.
venkat28vk
25-May-15 7:42am
View
I have already tried with tar -xvf command in command prompt,but it is not working.Is there any possibility through the code.
venkat28vk
25-May-15 7:25am
View
Also i have tried with multiple sets of file transfer size like above 2 MB, 20 KB file, but the end result is whatever the file maybe there is some data loss happening.
venkat28vk
25-May-15 7:20am
View
Deleted
#include<stdio.h>
#include<unistd.h>
#include<string.h>
#include<stdlib.h>
#include<sys ioctl.h="">
#include<sys types.h="">
#include<arpa inet.h="">
#include<sys socket.h="">
int receive_text(long int new_socket)
{
int buffersize = 0, recv_size = 0, size = 0, read_size, write_size;
char verify = '1';
int errno;
FILE *text;
char *pBuf;
//Find the size of the text
recv(new_socket, (char *)&size, sizeof(int), 0);
//Send our verification signal
send(new_socket, &verify, sizeof(char), 0);
text = fopen("/home/sosdt009/Desktop/received.txt", "w");
if (text == NULL)
{
puts("Error has occurred. Text file could not be opened \n");
return -1;
}
//Loop while we have not received the entire file yet
while (recv_size < size)
{
ioctl(new_socket, FIONREAD, &buffersize);
//We check to see if there is data to be read from the socket
if (buffersize > 0)
{
pBuf = malloc(buffersize);
if (!pBuf)
{
fprintf(stderr, "Memory Error. Cannot allocate!\n");
exit(-1);
}
//memset(pBuf,0,buffersize);
read_size = recv(new_socket, pBuf, buffersize, 0);
if (read_size < 0)
{
printf("%s", strerror(errno));
}
//Write the currently read data into our text file
write_size = fwrite(pBuf, 1, buffersize, text);
printf("%d \n", write_size);
free(pBuf);
//Increment the total number of bytes read
recv_size += read_size;
printf("%d \n", recv_size);
}
}
fclose(text);
return 1;
}
int main(int argc , char *argv[])
{
int socket_desc , new_socket, c, read_size, buffer = 0;
struct sockaddr_in server , client;
char *readin;
//Create socket
socket_desc = socket(AF_INET,SOCK_STREAM,0);
if (socket_desc == -1)
{
printf("Could not create socket:");
}
//Prepare the sockaddr_in structure
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons( 6777 );
//Bind
if( bind(socket_desc,(struct sockaddr *)&server , sizeof(server)) < 0)
{
puts("bind failed");
return 1;
}
puts("Bind completed");
//Listen
listen(socket_desc,3);
//Accept and incoming connection
puts("Waiting for incoming connections...");
c = sizeof(struct sockaddr_in);
if((new_socket = accept(socket_desc,(struct sockaddr *)&client,(socklen_t *)&c)) )
{
puts("Connection accepted");
}
fflush(stdout);
close(socket_desc);
if (new_socket<0)
{
perror("Accept Failed");
return 1;
}
while(1)
{
receive_text(new_socket);
}
close(socket_desc);
return 0;
}
This is the C code
venkat28vk
25-May-15 5:18am
View
I am trying to send a text file from Android to C using TCP/IP Protocol. If Android is sending a text file i am able to receive the text file, but not completely(there is a loss of bytes in the received text file). So i thought of zipping the text file and sending to C, where i can extract the file.
venkat28vk
25-May-15 5:10am
View
Kindly look for my updated question.
venkat28vk
20-May-15 4:31am
View
And moreover i shall add some debugging statements to it.
venkat28vk
20-May-15 4:30am
View
Yes the sending program has sent all the data, because once all the data are sent they will get a confirmation on their screen stating that the process has been done and the file is sent.
venkat28vk
20-May-15 0:49am
View
Moved to question [rjm]
venkat28vk
18-May-15 8:57am
View
There are no errors in c code, problem is i have checked by transmitting a single byte by byte from android to C, but still there are some loss at the last of the file.
venkat28vk
18-May-15 3:10am
View
The problem is when android is sending a file below 1 MB i am not able to receive the file, and the received file size is zero, But if the file size is above 1MB i am able to receive the file with data loss(mismatch in bytes). How to overcome this.
venkat28vk
13-May-15 2:42am
View
Hi, thanks for the help i am able to transfer text, image, audio and video files between two systems without data loss. Thanks for the help provided.
venkat28vk
2-May-15 4:49am
View
My system is Ubuntu and the system i am transferring all the data is also Ubuntu. The problem is when i send the images, the receiver is able to receive the image, but when i open the image, i am getting an error stating that "the image file could not be opened" i have tried changing the format also from .jpg to .png. But still the image is not working between two systems. The same happens for video also.
venkat28vk
30-Apr-15 0:25am
View
I am just sending a file of size 2-5 MB, in image and also video but that it not working. I am able to receive the file but it is not playing.
venkat28vk
29-Apr-15 8:11am
View
Everything is working fine now. Thanks for the help you have provided. I am able transfer audio files between two systems. Thanks a lot for what you have given. I have next tried with the images and video, the data is getting transferred but the file is not playing and in image there is an error message shown, when the image is opened in the received side. What could be the causes of errors?
venkat28vk
29-Apr-15 5:42am
View
I tried the above code between two different systems as client and server, but still i am not able to see the file in the desired path. Are there any other changes to be made.
venkat28vk
28-Apr-15 6:47am
View
how can i transfer the file into small chunks, because though i am sending a complete file, in networking all the files are transferred as a small packets or chunks. Can i use strtok() to achieve this?
venkat28vk
28-Apr-15 6:24am
View
When i run the above code in two different machines i get no errors and i don't find the file.
venkat28vk
28-Apr-15 6:04am
View
just run the server and client code by changing the path name and enabling port no in your system. you shall get a clear picture.
venkat28vk
28-Apr-15 5:55am
View
similar to the code above instead of strcpy i am using send and receive function to read and write data in client server communication.
venkat28vk
28-Apr-15 5:29am
View
In the code, i have added the "read and write mode" to send and receive file between client and server.
venkat28vk
28-Apr-15 5:23am
View
Deleted
When i run the below code in my localhost it is working fine i am able to read and write the file and audio also is playing .
venkat28vk
28-Apr-15 5:21am
View
Deleted
Client code :
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys socket.h="">
#include<sys ioctl.h="">
#include<sys types.h="">
#include<arpa inet.h="">
#include<unistd.h>
//using namespace std;
//This function is to be used once we have confirmed that an audio is to be sent
//It should read and output an audio file
long long int receive_audio(long long int socket)
{
long long int buffersize = 0, recv_size = 0,size = 0, read_size, write_size;
char audioarray[1024000],verify = '1',errno;
FILE *audio;
//Find the size of the audio
read(socket, &size, sizeof(int));
//Send our verification signal
write(socket, &verify,sizeof(char));
//Make sure that the size is bigger than 0
if(size <= 0 )
{
printf("Error has occurred. Size less than or equal to 0 \n");
return -1;
}
audio = fopen("/home/sosdt009/Desktop/received.mp3", "w");
if( audio == NULL)
{
printf("Error has occurred. audio file could not be opened \n");
return -1;
}
//Loop while we have not received the entire file yet
while(recv_size < size)
{
ioctl(socket, FIONREAD, &buffersize);
//We check to see if there is data to be read from the socket
if(buffersize > 0 )
{
if(read_size = read(socket, audioarray, buffersize) < 0){
printf("%s", strerror(errno));
}
//Write the currently read data into our audio file
write_size = fwrite(audioarray,1,(buffersize), audio);
/* if(write_size != buffersize)
{
printf("write and buffer sizes are wrong \n");
}
if(read_size != write_size)
{
printf("error in read write \n");
} */
//Increment the total number of bytes read
recv_size += read_size;
//Send our handshake verification info
write(socket, &verify, sizeof(char));
}
}
fclose(audio);
printf("audio successfully Received! \n");
return 1;
}
long long int main(int argc , char *argv[])
{
long long int socket_desc;
struct sockaddr_in server;
char *parray,errno;
//Create socket
socket_desc = socket(AF_INET,SOCK_STREAM,0);
if (socket_desc == -1)
{
printf("Could not create socket \n");
}
memset(&server,0,sizeof(server));
server.sin_addr.s_addr = ("10.170.0.40");;
server.sin_family = AF_INET;
server.sin_port = htons(6888);
//Connect to remote server
if (connect(socket_desc,(struct sockaddr *)&server , sizeof(server)) < 0)
{
// printf(strerror(errno));
close(socket_desc);
printf("Connect Error \n");
return -1;
}
puts("Connected \n");
receive_audio(socket_desc);
close(socket_desc);
return 0;
}
venkat28vk
28-Apr-15 5:20am
View
Deleted
Server code:
#include<stdio.h>
#include<string.h>
#include<sys types.h="">
#include<sys socket.h="">
#include<arpa inet.h="">
#include<stdlib.h>
#include<sys ioctl.h="">
#include<stdarg.h>
#include<setjmp.h>
#include<errno.h>
#include<assert.h>
//using namespace std;
long long int send_audio(long long int socket)
{
FILE *audio;
long long int size, read_size, stat, packet_index;
char send_buffer[1024000], read_buffer[1024000];
packet_index = 1;
audio = fopen("/home/sosdt009/Desktop/ROBO.mp3", "r");
printf("Getting audio Size\n");
if(audio == NULL)
{
printf("Error Opening audio File");
}
fseek(audio, 0, SEEK_END);
size = ftell(audio);
fseek(audio, 0, SEEK_SET);
printf("Total audio size: %lli \n",size);
//Send audio Size
printf("Sending audio Size\n");
write(socket, (void *)&size, sizeof(int));
//Send audio as Byte Array
printf("Sending audio as Byte Array\n");
do
{
//Read while we get errors that are due to signals.
stat=read(socket, &read_buffer , 255);
printf("Bytes read: %lli \n",stat);
}
while (stat < 0);
printf("Received data in socket\n");
printf("Socket data: %s\n", read_buffer);
while(!feof(audio))
{
//while(packet_index = 1){
//Read from the file into our send buffer
read_size = fread(send_buffer, 1, sizeof(send_buffer)-1, audio);
//Send data through our socket
do
{
stat = write(socket, send_buffer, read_size);
}
while (stat < 0);
printf("Packet Number: %lli \n",packet_index);
printf("Packet Size Sent: %lli \n",read_size);
printf(" \n");
printf(" \n");
packet_index++;
//Zero out our send buffer
bzero(send_buffer, sizeof(send_buffer));
}
}
long long int main(int argc , char *argv[])
{
long long int socket_desc , new_socket, c, read_size, buffer = 0;
struct sockaddr_in server , client;
char *readin;
//Create socket
socket_desc = socket(AF_INET , SOCK_STREAM , 0);
if (socket_desc == -1)
{
printf("Could not create socket");
}
//Prepare the sockaddr_in structure
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons( 6888 );
//Bind
if( bind(socket_desc,(struct sockaddr *)&server ,sizeof(server)) < 0)
{
puts("bind failed");
return 1;
}
puts("Bind completed");
//Listen
listen(socket_desc,3);
//Accept and incoming connection
puts("Waiting for incoming connections...");
c = sizeof(struct sockaddr_in);
if((new_socket = accept(socket_desc,(struct sockaddr *)&client,(socklen_t *)&c)))
{
puts("Connection accepted");
}
fflush(stdout);
if (new_socket<0)
{
perror("Accept Failed");
return 1;
}
send_audio(new_socket);
close(socket_desc);
fflush(stdout);
return 0;
}
venkat28vk
28-Apr-15 5:19am
View
I shall share the audio code for both client and server.
venkat28vk
28-Apr-15 5:18am
View
I am trying to send a audio file from my system to another system. There is no error but the file is not written there.
venkat28vk
28-Apr-15 1:37am
View
As per you said the connection has been established, but the file is not getting transferred. Could you say what could be the problem and are there any issues regarding firewall?
venkat28vk
28-Apr-15 1:35am
View
You are saying to specify the ip address of the server in client code and in server address can i put it as INADDR_ANY or do i need to change to client ip address
venkat28vk
28-Apr-15 0:15am
View
i have tried ping also, everything is working fine.
venkat28vk
27-Apr-15 7:57am
View
Is the code correct? I am running the server code in my system and the client code in another system, but i am facing problems in this.
venkat28vk
27-Apr-15 7:47am
View
Yes i have used like that, connect in client and listen in server for connection establishment.
venkat28vk
27-Apr-15 7:42am
View
I have added the code for further reference, could you share me your ideas for resolving my issue.
venkat28vk
27-Apr-15 7:40am
View
I am trying to run client server communication using tcp/ip in two different systems, but i am facing a problem in connection establishment. I have added the code, could you skim through it and let me know what has to be changed.
venkat28vk
27-Apr-15 7:36am
View
I tried by disabling the firewall, but it is not working.
venkat28vk
27-Apr-15 7:29am
View
i shall try, thanks
venkat28vk
27-Apr-15 7:29am
View
I have done the coding, but when running in my system i able to read and write data, but when i run the code between two different systems i am facing a problem in connection establishment. What are the causes of errors?
venkat28vk
27-Apr-15 7:20am
View
I have tried the code and i am facing the problem in establishing connection from server to client.
venkat28vk
27-Apr-15 7:19am
View
i have tried with the code, from my system to my friends system in LAN, but it is not working. Could you assist me in resolving this issue.
venkat28vk
20-Apr-15 8:44am
View
I have used write as per you said, but still it is not working. Are there any other way for resolving this?
venkat28vk
20-Apr-15 4:33am
View
what can i do? Can you suggest how to do achieve this
venkat28vk
16-Apr-15 3:42am
View
I have done what you have said, for example i have sent an audio file from android to C using tcp/ip protocol. I have received the audio file but with some data loss in it. For ex 4 bytes is sent i am able to receive 4 bytes but there is a mismatch in the bytes when i check the properties. But the file is playing good how to overcome the few data loss.
venkat28vk
13-Apr-15 1:21am
View
yes just 4kb files, but the problem here is i am able to receive audio file greater than 4 MB but when it comes to sending an entire text file i am facing issues.
venkat28vk
13-Apr-15 0:55am
View
As per your requirements, i have given the code and i hope you can get an idea of what the code is... now i am able to receive the text file but sometimes only partial data is transferred. Could you provide me some suggestions.
venkat28vk
7-Apr-15 2:00am
View
How do you think a question has to be posted, by your comments i feel that my question should be represented in a better way. Could you say how to put more effective questions.
venkat28vk
7-Apr-15 1:49am
View
Just look for the code i have added it.
venkat28vk
7-Apr-15 1:23am
View
I am sending a text file of size 1kb from Android, bu i am able to receive only the half of it...
venkat28vk
7-Apr-15 1:19am
View
I would like to share my code for your reference, if you would be interested in helping me by resolving this issue.
venkat28vk
7-Apr-15 1:19am
View
I am sending through sockets only, the problem is i am able to receive only half of the file.
venkat28vk
21-Mar-15 8:14am
View
If you want i can share the code
venkat28vk
21-Mar-15 8:13am
View
Hi
I have tried all the option as you have said...i am able to run the code in my local machine i.e reading from server and writing into client. But when it is sent from Android i am facing the above problem
venkat28vk
19-Mar-15 0:29am
View
I am using TCP/IP
venkat28vk
2-Mar-15 4:14am
View
I want to send a complete text file from C to Android.. Do you have any idea of how you can achieve it.
venkat28vk
11-Feb-15 23:30pm
View
I have tried for sending audio between client and server but i am not able to get the proper result...can you suggest me few links for further references.
venkat28vk
11-Feb-15 0:00am
View
i have developed the code for client and server, and i like to share with you, could you just skim through it and give your feedback
venkat28vk
10-Feb-15 6:15am
View
ok... do i need to serialize the data into streams for the required output?
venkat28vk
10-Feb-15 1:01am
View
could you share any links or some kind of references
venkat28vk
4-Feb-15 23:41pm
View
Hi Richard, I am able to receive images of very small size less than 5kb from android to C via TCP/IP, if i go for bigger size images i am not able to receive. Kindly do share your feedback
venkat28vk
3-Feb-15 5:17am
View
I want to know how it working fine for few images and it does not work for the rest. If there is an error, i want to know how only certain images face the problem..
venkat28vk
3-Feb-15 4:29am
View
And one more thing the android team is also facing similar problem like this... they are encountering a system error when new images are sent to C via TCP/IP. suggest me to resolve this issue.
venkat28vk
3-Feb-15 4:27am
View
Hi Richard i am able to receive images from android to C via TCP/IP. But the problem is i am able to receive only certain set of images, if other img are sent i am getting an error stating that
"Connection accepted
Error has occurred. Size less than or equal to 0"
this is the error i am getting could you share your idea on how to overcome this
venkat28vk
21-Jan-15 6:52am
View
and i want to thank you for providing your greatest support till the end thanks a lot for your help
venkat28vk
21-Jan-15 6:51am
View
yes i have tried all the possibilities.. but again i will look through the code
venkat28vk
21-Jan-15 6:43am
View
and moreover i have also used the same name in the receiving end also with the same extension.
venkat28vk
21-Jan-15 6:39am
View
i am receiving .jpg file in the name i have created
venkat28vk
21-Jan-15 6:21am
View
if you don't mind can you come to skype so that we can have a better conversation without taking so much of time and if so ping me your skype id
venkat28vk
21-Jan-15 6:19am
View
.jpg only i used it for testing purpose. I just want to check the size of the image i receive, that is the reason i changed it to .png
venkat28vk
21-Jan-15 5:38am
View
kindly revert the changes to me if you find anything in the improved code
venkat28vk
21-Jan-15 5:25am
View
kindly go with the original post just check whether i have used it correct or not
venkat28vk
21-Jan-15 5:05am
View
for your better understanding and also know the solution for this problem
venkat28vk
21-Jan-15 4:52am
View
can i share the full code
venkat28vk
21-Jan-15 4:46am
View
yeah they are sending jpeg file, i have also tried with .png both have not worked
venkat28vk
21-Jan-15 4:29am
View
i have tried with "a", "w+" also but still i am not able to receive the image
venkat28vk
21-Jan-15 4:05am
View
richard i have tried every possibilities but still i am struggling here, is it possible to try with UDP will it work?
venkat28vk
21-Jan-15 3:43am
View
the core part is already given, and you have said your valuable comments and i have added it, even after that too i am unable to receive the image kindly guide me in resolving this issue.
venkat28vk
21-Jan-15 3:41am
View
When i am opening that image sent from android to C i am getting 'Could not load image 'newimg.jpg' Error interpreting JPEG image file (Improper call to JPEG library in state 200) this is the error i am getting when i open the received file
venkat28vk
21-Jan-15 1:15am
View
can i post my entire code for better understanding
venkat28vk
20-Jan-15 23:34pm
View
after compiling this code i have got an error after i have opened the img
Error interpreting JPEG image file (Improper call to JPEG library in state 200) what does this implicate,
venkat28vk
20-Jan-15 0:01am
View
char* fr_name = "/home/sosdt011/Desktop/newimg.jpg";
FILE *fr = fopen(fr_name, "a+");
if(fr == NULL)
{
printf("File %s Cannot be opened file on server.\n", fr_name);
}
else
{
//bzero(revbuf, LENGTH);
int fr_block_sz = 0;
while((fr_block_sz = recv(nsockfd, revbuf, LENGTH,0)) > 0)
{
int write_sz = fwrite(revbuf, 1 , sizeof(fr_block_sz) , fr);
if(write_sz < fr_block_sz)
{
error("File write failed on server.\n");
}
bzero(revbuf,LENGTH);
if (fr_block_sz == 0 )
{
break;
}
}
if(fr_block_sz < 0)
{
if (errno == EAGAIN)
{
printf("recv() timed out.\n");
}
else
{
fprintf(stderr, "recv() failed due to errno = %d\n", errno);
exit(1);
}
}
printf("Ok received from client!\n");
fclose(fr);
}
success = 1;
close(nsockfd);
printf("[Server] Connection with Client closed. Server will wait now...\n");
while(waitpid(-1, NULL, WNOHANG) > 0);
could you guide me in sorting this out
venkat28vk
20-Jan-15 0:01am
View
Deleted
char* fr_name = "/home/sosdt011/Desktop/newimg.jpg";
FILE *fr = fopen(fr_name, "a+");
if(fr == NULL)
{
printf("File %s Cannot be opened file on server.\n", fr_name);
}
else
{
//bzero(revbuf, LENGTH);
int fr_block_sz = 0;
while((fr_block_sz = recv(nsockfd, revbuf, LENGTH,0)) > 0)
{
int write_sz = fwrite(revbuf, 1 , sizeof(fr_block_sz) , fr);
if(write_sz < fr_block_sz)
{
error("File write failed on server.\n");
}
bzero(revbuf,LENGTH);
if (fr_block_sz == 0 )
{
break;
}
}
if(fr_block_sz < 0)
{
if (errno == EAGAIN)
{
printf("recv() timed out.\n");
}
else
{
fprintf(stderr, "recv() failed due to errno = %d\n", errno);
exit(1);
}
}
printf("Ok received from client!\n");
fclose(fr);
}
success = 1;
close(nsockfd);
printf("[Server] Connection with Client closed. Server will wait now...\n");
while(waitpid(-1, NULL, WNOHANG) > 0);
this is the receiving code could help me by sorting this out
venkat28vk
12-Jan-15 8:06am
View
Deleted
i shall say this to u in detail
venkat28vk
12-Jan-15 7:52am
View
the code is replica of tcp/ip communication, for any reference if you need i shall give u the code...
venkat28vk
2-Jan-15 5:48am
View
ok thanks a lot i shall try that and see
venkat28vk
2-Jan-15 4:02am
View
Hi george thanks for the answer you have provided, do you have any idea how does it work in unix because i am not using windows, i am using ubuntu so you must be aware how the code differs to the various environment.... and i would be glad if you could provide a sample code for the above
venkat28vk
2-Jan-15 1:51am
View
i am sorry for not specifying correctly... you are right i am using sockets to send and receive images. can this be achieved in the above
venkat28vk
2-Jan-15 1:36am
View
hi
i am using tcp/ip programming, i think you must be aware of sending and receiving text between a server and client, similarly i have to send and receive images i hope this clarifies your doubt...
venkat28vk
29-Dec-14 8:30am
View
do you have any idea about this, if so kindly share with me
venkat28vk
29-Dec-14 8:00am
View
the ultimate cause is i shall receive set of data from android, for every data i receive i must send a ack stmt to android stating that data has been received! i am able to receive data but how to send ack stmt for every single data?
venkat28vk
29-Dec-14 7:52am
View
ok, is there any keyword or function for sending?
venkat28vk
29-Dec-14 7:45am
View
Hi,
I need to send a ack message to the server stating that i have received data and how to achieve this in the code....could you show me some sample...for better understanding if you want i can share my code
venkat28vk
9-Oct-14 5:26am
View
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
void main( )
{
FILE * fp;
char name[300],city[300],dept[300];
/* fp=fopen("sampledata.ods", "r");*/
if(!fp) {
printf("Failed to open!\n");
exit(1);
}
fp=fopen("/home/sosdt011/Desktop/sampledat.ods","r");
fscanf(fp,&name);
/* fp=fopen("/home/sosdt011/Desktop/sampledat.ods","r");*/
fprintf(stdout,"First Line is %s\n", *name);
fclose(fp);
}
This is the code and i am getting segmentation fault core dumped can someone help me to solve this
venkat28vk
8-Oct-14 5:58am
View
Can I have the syntax to open the text(.odt file in ubuntu)
venkat28vk
8-Oct-14 5:46am
View
how to open a text file(ubuntu it is .odt) could you specify me the syntax
Show More