C/C++ :: Send JPG File From Client To Server?
Feb 27, 2013Share ur code wit my. m working on windows n using visual studio 2008..
View 1 RepliesShare ur code wit my. m working on windows n using visual studio 2008..
View 1 RepliesHere is what I got so far, I am not able to send whats in the txt file to the server. Its pretty much a txt file with movie names and when the client types the name, it brings up the movie and its ranking (all from the txt file)
Server Code::
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <string.h>
#include <fcntl.h> //file control
[Code] .....
I attached the images of the client and server when I run this, along with the movie.txt file. I cannot seem to get the file to send to the client?
Attached image(s)
I am not able to send whats in the txt file to the server. Its pretty much a txt file with movie names and when the client types the name, it brings up the movie and its ranking (all from the txt file) .....
Server Code::
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
[code]....
I attached the images of the client and server when I run this, alongside the movie.txt file. I cannot seem to get the file to send to the client
First of all i create single server single client program and then using thread i make multiple client to connect to server.
while(true){
csock = (int*)malloc(sizeof(int));
if(nClient<=maxClient){
if((*csock = accept( hsock, (SOCKADDR*)&sadr, &addr_size))!= INVALID_SOCKET ){
[Code].....
The clients send message to the server and server echo back the message to that particular client. But i want that the server will echo back ones's message to all clients. Suppose 5 clients are connected to the server. So whenever one client send a message to the server, the server will send that message to all 5 clients.
i am making a client server application but the problem is that i cannot send data from CLIENT to SERVER , but i can receive data from SERVER to CLIENT ... Below is mt client and Server code and i also have attached both client and server files...
CLIENT CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace asynclient {
[code]....
I am trying to repetitively send the screen bitmap buffer of a client to a server. The program works perfect when the client and server are running on the same machine, otherwise the server receives a distorted buffer. The distorted buffer received by the server seems to start from a byte which was not the starting byte of a buffer sent by the client (I am not sure). w=1366 and h=768 are the screen width and height respectively of both the server and the client.
Client code:
while (connect(sSocket,(sockaddr*)&addr,sizeof(addr))!=0) {}
while (!GetAsyncKeyState(VK_ESCAPE)) {
s=4*w*h;
while (s>0) {
n=send(sSocket,buf,s,0); s-=n;
for (i=0; i<s; i++) {buf[i]=buf[i+n];}
}
BitBlt(MemDC,0,0,w,h,hdc,0,0,SRCCOPY);
GetDIBits(MemDC,hBit,0,h,buf,&bmi,DIB_RGB_COLORS);
}
Server code:
do {rSocket=accept(hSocket,(sockaddr*)&addr,&addrlen);}
while (rSocket==INVALID_SOCKET);
while (!GetAsyncKeyState(VK_ESCAPE)) {
s=4*w*h; while (s>0) {n=recv(rSocket,buf,s,0); s-=n;}
SetDIBitsToDevice(hdc,0,0,w,h,0,0,0,h,buf,&bmi,DIB_RGB_COLORS);
}
I have to make a server-client file transfer using UDP . I have created a basic server which receives message sent by client . That's all. Now comes the major part :-
1. The message sent by client is the name of file
.2. Now the server checks whether there exists this file or not .
3. If there exists it sends the file to the client and it also keeps the count of the number of requests of file made by the client . Here is the Server Code
Code:
#include<sys/socket.h>
#include<arpa/inet.h>
#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<sys/types.h>
#include<string.h>
}
[code]...
The server reads the data from file and writes into it and send to the client , On the other end client receive the data and make duplicate of this file and write into it. But on compiling it gives error in reading the file.
I have a client/server program. My Client process spawns my server process using a `fork()` and `system()` call. The client and the server are meant to communicate to each other through named piped, that is a requirement of my homework. The client and the server are supposed to initially send a message to the other one, through a pipe, to confirm that a connection is made. My issue is that my client is trying to open one of the named pipes before the server has a chance to make it. This doesn't always happen though. Occasionally, it will run fine. Is there some way to synchronize this?
My overall goal is to get a filename and search target from the user, send those to the server through a named pipe. And the server searches for the target and sends info back.
OUTPUT:
Client: PID 2986 - Running on Tue Sep 30 20:59:28 2014
Client: PID 2986 - Enter File Name: largeSampleText.txt
Server PID 2988 - Running on Tue Sep 30 20:59:32 2014
Server: PID 2988 - Synchronized to Client.//This means the client-to-server fifo is working
There was an error opening serverToClientfifo//This means client couldn't open the server-to-client fifo
error is: 2//This means the fifo doesn't exist yet
[Code] ....
CORRECT OUTPUT:
Client: PID 2542 - Running on Tue Sep 30 20:58:44 2014
Client: PID 2542 - Enter File Name: largeSampleText.txt
Server PID 2557 - Running on Tue Sep 30 20:58:54 2014
Server: PID 2557 - Synchronized to Client.
[Code] ....
RELEVANT CLIENT CODE:
int main() {
char requestedFileName[1024];
//Get initial information on the client
pid_t clientPID = getpid();
time_t currentTime = time(0);
char* stringTime= ctime(¤tTime);
[Code] ....
I tried creating both of my fifos in my client and my output changed to this
Client: PID 3150 - Running on Tue Sep 30 21:23:17 2014
Client: PID 3150 - Enter File Name: largeSampleText.txt
Client: PID 3150 - Enter Target:
Server PID 3153 - Running on Tue Sep 30 21:23:21 2014
was
Client: PID 3150 - Input File >>>largeSampleText.txt<<<
Client: PID 3150 - Target >>>was<<<
Client: PID 3150 - Synchronized to Server
Server received unexpected connection message
Message: was
Terminating
So It appears like the client went ahead and put `requestedFileName` and`requestedTarget`into the pipe and the server read out `requestedTarget` instead of the connection message. Not sure why though
i have to upload a ms access database file to the server from my client program. The server program should connect to this database and read the data. What's the easiest way to upload the file? Is it FTP? i tried sockets, but it only allows like 9kb of data transfer capacity.
View 3 Replies View RelatedI need to create a client and server program. The client will have a GUI that will display all the available servers (since more than one will be running) in a list box.
I’m guessing a TCP connection will be the best method here, but how will the client find the servers to connect to? I won’t know the IP address of the server because anyone could take the server program and run it on their computer and the client would have to find it.
Is there some way to make the server send some kind of signal that only the client application will be to connect to? So the server will be sending out a signal, the client finds the signal and connects to the server. Is this possible?
i also need to be able to store the IP address the client selects so when the client application is run again it will automatically connect to the server that was stored.
I need the code for multithreaded server and client code. one server and two or more client connect to server.
Without fork(),semaphore(),etc
I'm building a client server which is communicating.I am trying to use the function recvfrom, but have several bugs, so I might have the recvfrom function in the wrong part of my code.
Code:
int talk_with_server(int fd) {
printf("Test.
");
char buf[LEN];
int n = read(fd, buf, LEN);
[Code]....
I have loads of movies on DVD and they are all on my media server, but the media server doesn't actually allow streaming to be done, the movies are just stored in a folder on the desktop.
My goal would be able to host all my movies on my LAN server, then build an application to run on a windows based PC at home, not over the Internet just over LAN. For example, say the server I have at home had all the movies in a folder on the desktop, then when I start the client on another PC or laptop in my house, I could view all the movies, choose which one and then stream it to that client PC. I am using C#.NET WPF visual studio.
Maybe I could use something like VLC player to play the movies but I would want to build an client application to view the movies and search for them on the server where the movies are stored. Also I know there are other media streaming programs out there but I want to develop my own one for my uses.
I am using the following code that I copied from a website to send some numbers using TTcpServer in C++.
void __fastcall TForm2::Button1Click(TObject *Sender) {
//Creating a stream
std::auto_ptr<TMemoryStream> myStream(new TMemoryStream);
for (byte i = 0; i < 9; i++) {
myStream->WriteBuffer(&i,1);
[code]....
I do not understand what is being sent in the byte variable, nor why a byte variable was used. I want to send some strings instead of numbers, but I don't understand what's taking place so I can't identify what to change.
ok to start, windows based program, using pelles c ide
winsock2, using "sample" codes, able to connect, BUT no clue what 1/2 of the codes do, and most of the coding is for nix based systems!
trying to understand, and implement a minimal amount of code to add to a current menu based program!
being able to open connection, wait for input from server, receive input, acknowledge the input, then "act" then return to waiting for new input.
or vice versa, server waiting on client (but then server would have to send all the current status`s to client, so that client could be in real time, prob by sending an array from server to client).
So I've just been messing with enet trying to figure out how to make a server and client for a game. I'm having problems whenever the server receives something from a client. For now I'm just trying to send it to all the clients for them to draw the other player, but for some reason whenever I try to an error message comes up saying a breakpoint has been triggered. I don't know why it is happening. This is the code that is giving me problems.
for (unsigned int i = 0; i < peers.size(); i++)
enet_peer_send(peers[0], 0, event.packet);
I want to write a little c++ program that sends a request to a server an get some data. I found the C++ Rest-SDK and decided to use it. I searched on different websites for code-examples but many of them doesn't work an shows syntax errors. What i got now is that code but the client.request method is skipped. The program never jumps in.
#include <Windows.h>
#include <iostream>
#include <sstream>
#include <string>
#include "cpprest/containerstream.h"
#include "cpprest/filestream.h"
[Code] .....
I completed the program but how insert three values without using struct???
Server Program
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <iostream>
#include <netdb.h>
#include <errno.h>
#include<map>
[Code] .....
How to free the memory and address,value
Server:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
[Code] .....
Client:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
[Code] .....
I made client server program with fork ,without using signal handler because I want to see the status zombie for parent server, but when i execute "ps" command i didn't see anything for server or client pid or ppid ,i wonder about how to show the server and client process coz when i execute commad "ps" i saw only ps and bash processes???
View 1 Replies View Relatedhow send and receive images from linux server to windows client?
View 2 Replies View RelatedI have created a Server that can handle multiple users with the select function. The server seems to be operating just fine on every new request of a client even on the case of termination connection. The problem appears on the client side. I am applying forking process to be able to hear and write at the same time while the user is typing a message to the rest of the clients. By doing so I discovered that when the client is initialized it send a blank message to the server. The server then send this blank message to all the clients. I have discovered a "trick" not to display the message on the client side but I really would like to know if there is an alternative solution instead of my solution. I mean why it dose not wait for the client to first start typing a message before to send it.
The communication that will apply on each new connection is:
Client Server
Connect() −− >
< −− Hello version
NICK nick −− >
< −− OK/ERROR text
MSG text −− >
< −− MSG nick text/ERROR text
Sample of the Server.c code:
#include <stdio.h> /* stderr, stdout */
#include <errno.h> /* errno.h - system error numbers */
#include <stdlib.h> /* memory allocation, process control etc. */
[code].....
I'm currently in the middle of designing a program for some project. one part of the program is to send reminding SMS messages to the employees.
I have already subscribed to a SMS provider and they gave me an access to a control panel (aspx). But now I'm wondering how will I be able connect to the SMS server and be able to send messages?
When server send data then client receive that data, in C# windows services where data receive continuously (Using IP Address and port number) . This below code writing in console application . i want implement same logic in windows service side. but i want data receive continuously.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
[Code]....
Above code write in console application, same logic implementing in windows service, but i want data receiving continuously
What happens if I make a server application using tcp protocol and then establish connection with a client application but the server crash and then the client send data. Will the data be lost or the system will continue trying to send it?
View 2 Replies View RelatedI am trying to make kind of a messenger using Socket/Network Programming
My program should allow clients to register or sign in, after they are signed in they should see a list of the other signed in people whoever I select from that list I should be able to implement using multiple threads as well.
I have done this much:
User.txt file
ahsan,1234
bilal,1234
pappu,1234
babu,1234
Client.c
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
[code]....
Now issue is in this code I am getting error SEGEMENTATION ERROR, CORE DUMP