Looking for conceptual help... I am writing a program in C++ to handle socket connections, eventually to be a websocket server. However, the rest of my stack uses PHP for serving up page. Is there a way to use PHP as an intermediary between the client (JS) and the application (so I don't have to keep track of session data or state in the database to retrieve with each incoming socket request)? I understand I can't pass the resource (a socket) to the application from PHP, but could I do a 302 with the request from the client? Could I …

Member Avatar
Member Avatar
+0 forum 3

0 down vote favorite I have created a network scanner, that looks for a specific port on a range of IP's. I would like to thread the application but I am getting and error message ERROR: for worker in range(network.hosts): TypeError: 'method' object cannot be interpreted as an integer Now I understand why the error is there it is because the IP Address is not an INT. However, what I would prefer to do is split the subnet into equal parts and run X number of IP's on a per thread bases. Example Thread 1 192.168.1 - 30 Thread 2 …

Member Avatar
Member Avatar
+0 forum 1

I'm trying to develop an app that realises the communication between a gameserver and an applcation. My code so far is: #include <cstdlib> #include <iostream> #include <boost/bind.hpp> #include <boost/asio.hpp> #include <boost/asio/ssl.hpp> using namespace std; enum { max_length = 1024 }; class client { public: boost::asio::streambuf receive_buffer; client(boost::asio::io_service& io_service, boost::asio::ssl::context& context, boost::asio::ip::tcp::resolver::iterator endpoint_iterator) : socket_(io_service, context) { socket_.set_verify_mode(boost::asio::ssl::verify_peer); socket_.set_verify_callback( boost::bind(&client::verify_certificate, this, _1, _2)); boost::asio::async_connect(socket_.lowest_layer(), endpoint_iterator, boost::bind(&client::handle_connect, this, boost::asio::placeholders::error)); } bool verify_certificate(bool preverified, boost::asio::ssl::verify_context& ctx) { char subject_name[256]; X509* cert = X509_STORE_CTX_get_current_cert(ctx.native_handle()); X509_NAME_oneline(X509_get_subject_name(cert), subject_name, 256); return preverified; } void handle_connect(const boost::system::error_code& error) { if (!error) { socket_.async_handshake(boost::asio::ssl::stream_base::client, boost::bind(&client::handle_handshake, this, boost::asio::placeholders::error)); } else …

Member Avatar
Member Avatar
+0 forum 1

I made a client server program to send an image from the server to the client. The image is being sent being but its not showing up in client window immediately. If i click send on the server then i minimize (or maximize) the client window then open again the image will show up. But if i just click send and dont do anything to the client window nothing shows up until i resize it in some way. I'm not sure why its not just showing up in the client window. Any help would be really appreciated. thanks Server Code …

Member Avatar
Member Avatar
+0 forum 4

Hi Dw. Has anyone worked with TCP/IP socket in Windows Phone? I'm using Windows Phone 7 and I would like my app to communicate with my server which my client will send some data to the server and the server will also send some data to the client, It's more like chat server, but I'm not using it for chatting. I need some resources/source/samples. I've found samples but there are in C# and I tried converting it to VB.NET but it seems the code used doesn't match when converted to VB.NET.

Member Avatar
Member Avatar
+0 forum 3

Hi everyone, I seem to be having a bit of a weird problem with sockaddr / sockaddr_in structs... I want to manually assign the value of an IP address to the sockaddr_in struct, and I've been using memcpy memcpy (&(mIp4sa->sin_addr.s_addr), "127.0.0.1", INET_ADDRSTRLEN); But when I go to print out the IP address from the sockaddr_in struct using cout and inet_ntoa, I don't get the same address - in this case, I always seem to get 49.50.53.49 or something similiar :S I've tried casting a char* with the ip address to void* and using it in memcpy and the same thing …

Member Avatar
Member Avatar
+0 forum 4

I creating an application in visual studio where I have a client to request specific information to multiple servers. Someone Knows i can make this communication? For one server i know to create that, for many servers i dont have idea. Code example!!! One client for many servers! For one server i have this code: Try client.Connect(IPAddress, PortNum) RichTextBox1.Text() = "Connection is Accepted" Catch ex As Exception RichTextBox1.Text() = "Connection is Failed" End Try

Member Avatar
Member Avatar
+0 forum 3

I am writing simple server client programs using socket, in which a client would request a video file and the server should send it that file. After recieving the file the client would play that video file. I know how to open ordinary text files and binary files but can a video file be opened in the same manner i.e fopen ("file.avi", "rb"); and which library and its corresponding function should i use to play that video file on the client side.

Member Avatar
Member Avatar
+0 forum 4

Okay so i'm trying to make a chat application using sockets, and i want them both to be able to write and read simultaneously. So i did some research and found that I/O multiplexing like select() will fix this problem. But I still have one problem. After I compile it and run it, one of the two programs doesn't receive the message 'till after one responds. So for example, the server sends a message to the client right? Then the client won't see the message until AFTER the client responds. Below you can find an example of this as well …

Member Avatar
Member Avatar
+0 forum 2

I am having trouble as I am trying to run my clientsocket.connect until a connection has been established. However it is not running my connect method and I cannot seem to be able to diagnose why that is private static ClientSocket clientSocket = new ClientSocket(); private delegate void connection(); public Form1() { InitializeComponent(); connection waitConnect = callConnect; Console.WriteLine("before callconnect invoke"); IAsyncResult asyncConnect = waitConnect.BeginInvoke(null, null); Console.WriteLine("Main method now has control"); waitConnect.EndInvoke(asyncConnect); } private void callConnect() { while (!clientSocket.connected) { Thread.Sleep(1000); Console.WriteLine("still connecting..."); clientSocket.connect("127.0.0.1", 43); } } clientsocket.connected checks a connection has been established. If more information is needed I can …

Member Avatar
Member Avatar
+0 forum 3

Hi, I need to monitor the ip addresses in a server. whenever there is a fluctuation, i need to do some clean up (like restart the server/ reboot the machine) I was able to get a sample cpp program & was able to enhance it to suit my needs. But i think it would be better if i am able to convert it into a shell script as it will give me more flexibility in parsing the output. any body has got any idea of the syntax to be used for netlink sockets in shell script, since I could not …

Member Avatar
+0 forum 0

Hi there, I am trying to create a simple client/server application. Very basic - Client connects to server, client sends message to server - server receives message and broadcasts to any other connected clients. As I say - it is supposed to be simple and for the purpose of self teaching better understanding. As far as I can tell, the client is sending the data and I believe the difficulty is in the server receiving the data packets. Would anyone mind letting me know if there is something blindingly obviously wrong with my code. Many thanks in advance. Client: Imports …

Member Avatar
+0 forum 0

I'm making a messenger app and I need to know how to set up connections so that somebody could send messages to other via WI-FI.I googled a little and I find something at this page [Click Here](https://code.google.com/p/simple-android-instant-messaging-application/source/browse/trunk/src/com/mekya/communication/SocketOperator.java)but I don't understand it.Here is my main class/StartingPoint (all my code is just a skecht): import java.io.EOFException; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.InetAddress; import java.net.Socket; import android.os.Bundle; import android.app.Activity; import android.graphics.Color; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class StartingPoint extends Activity { Button bSend; TextView tvClient, etChat; String mess = ""; String name = "Name"; String usern = …

Member Avatar
Member Avatar
+0 forum 1

I am making a programe based on socket programing in which client can download one of the listed books from server. I have come up with this code but the problems with it are: 1) It doesnt downloads pdf file greater than 1MB. 2) It allows client to download 1 file only and then the connection is closed. I want the client to be able to download as many files as he/she wants. Please suggest improvements. ***CLIENT CODE:*** int filesize=10223860; int bytesRead; int currentTot = 0; Socket socket = new Socket("127.0.0.1",15123); BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); DataOutputStream outToServer = …

Member Avatar
Member Avatar
+0 forum 3

If you were to build a fairly complicated website, and you wanted to add features like instant messaging (one to one and multi-chat like a chat room, and possibly if the site becomes profitable enough, voice/video chatting) and you wanted to be able to store these chat sessions, would it be better to use AJAX or Web Sockets? What would be the pros and cons of each technology? p.s The backend development will be done with python and django. p.p.s An irrelvant question, but what would be the best way to store such communications to reduce redundancy, would you just …

Member Avatar
Member Avatar
+0 forum 1

Hello all i have asked a question related to this and i have solved the previous problem but now i am looking something more advance and i want to know a scenerio , i have implemented the SOCKETASYNCEVENTARGS class for a chat server in c# and it is working fine i have a pool of SAEA objects for connect , one for send and one for receive event.All is working fine but consider a scenerio where server will send more than two or two messages at the same time to a client as described for every client there will be …

Member Avatar
+0 forum 0

I wanna build a program that allows you to send a mail and advices you when you have new mail. I know that for this I have to kee it running in the background. Would you recommend using C++ for such a purpose? (It's pretty much a mail client for now, but latter I plan to add a ton of things). Also, I've read the best way to achieve this is trough sockets. Is that true? Could you recommend some articles on the topic? Thanks for all :)

Member Avatar
Member Avatar
+0 forum 1

I am trying to write a server-client application for file transfer: the client written in Java and the server written in C++. Unfortunately I have the following error: "java.net.SocketException: Connection reset by peer: socket write error". Here is my code for client: import java.io.*; import java.net.Socket; public class Proba_binar public static void main(String[] args) { byte[] buffer = null; byte[] auxByte = new byte[1000]; String fileName = "1.jpg"; File a_file = new File(fileName); try { // Create a socket Socket socket = new Socket("192.168.14.146", 8888); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); // Read file …

Member Avatar
Member Avatar
+0 forum 1

Hello, *We are very much begginers at programming in general, and it would be great if you could keep that in mind when helping us!* Could someone please explain just what a **socket** is? We are working on a program which will solve a 3D puzzle, handed to us by a known server. Basically what we need to do is establish a connection between the klient and the server, and "sockets" seem to be significant in this process. Many great thanks in advance!!

Member Avatar
+0 forum 0

I want to send string and save in different computer's database using c# using Asynchronous Any body Plz Help me finding a Solution

Member Avatar
Member Avatar
+0 forum 6

Hello! I'm just going to repost my question here from stackoverflow. I am currently developing a file sharing application using asynchronous communication in VB.Net. I successfully coded a simple connection between the client and the server. But, I am currently having a bad time doing the disconnection sub routine for both the client and the server. I'm currently stuck in this problem for a couple of days already and have decided to seek help here because I can't find any good ways to do the disconnection thing. Here's my code: **Server Application** Private Sub FileSharingInitialize() ServerSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, …

Member Avatar
Member Avatar
+0 forum 1

Hello Community, I was wondering if there is a way to make a program that will send messages from one computer to the other. **NOT** using LAN connection and **NOT** using winsock. EG. I (at my house) would like to chat with my friend (his at his house). Please help.

Member Avatar
Member Avatar
-1 forum 1

> this is my udp server code #include<iostream> #include<arpa/inet.h> #include<unistd.h> #include<sys/socket.h> #include<sys/types.h> #include<stdio.h> #include<string.h> #include<stdlib.h> using namespace std; void error( char *msg) { perror(msg); exit(EXIT_FAILURE); } int main() { int sockfd; sockfd = socket(AF_INET,SOCK_DGRAM,0); struct sockaddr_in serv,client; serv.sin_family = AF_INET; serv.sin_port = htons(53000); serv.sin_addr.s_addr = INADDR_ANY; char buffer[256]; socklen_t l = sizeof(client); //socklen_t m = client; cout<<"\ngoing to recv\n"; int rc= recvfrom(sockfd,buffer,sizeof(buffer),0,(struct sockaddr *)&client,&l); if(rc<0) { cout<<"ERROR READING FROM SOCKET"; } cout<<"\n the message received is : "<<buffer<<endl; int rp= sendto(sockfd,"hi",2,0,(struct sockaddr *)&client,l); if(rp<0) { cout<<"ERROR writing to SOCKET"; } } >this is my udp client code #include<iostream> #include<arpa/inet.h> #include<unistd.h> …

Member Avatar
Member Avatar
+0 forum 2

I am trying to understand how sockets work with winsock, but I just don't get it. I basically want to be able to create these functions: SomeDataType ConnectToComputer(const char *ConnectionName);//connect to the connection named ConnectionName SomeDataType CreateConnection(const char *ConnectionName);//create a connection called ConnectionName bool ReadData(SomeDataType, unsigned char *outdata, int outsize);//read outsize bytes into outdata from the connection and return on success void SendData(SomeDataType, unsigned char *data, int datalen);//send the data to the connection Basically this is what I want to be able to do with those functions: //This is called by the first computer to 'join' the room SomeDataType myConnection=CreateConnection("My …

Member Avatar
Member Avatar
+0 forum 3

im doing remote desktop project. i need to connect two sockets (each from single client) through the hashtable in the separate application server, so that client1 can see the desktop of the client2. can u suggest me solution for this? how can i achieve this? so far i can connect two client directly in the LAN in client- server base through socket. now i have to implement application server to make the remote desktop working in the internet. your suggestions will be valuable. thank you.

Member Avatar
Member Avatar
+0 forum 2

I've been working with python's SocketServer.ThreadingTCPServer a bit and I'm having some difficulty making a publicly available server. Everything works fine when I set the server address as 'localhost' [CODE=python]self.server = SocketServer.ThreadingTCPServer(('localhost', constants.cmdport), Handler)[/CODE] As long as the both the server and client are on the same computer and both specify 'localhost' the connections are made without a hitch. My program uses [URL="http://pypi.python.org/pypi/pystun"]pystun[/URL] to obtain my public ip. When I pass that public ip to the client and try to make a connection over the internet I get [errno 10061] No connection could be made..... as if the port was …

Member Avatar
Member Avatar
+0 forum 4

I am making a networking application using sockets for a local area network. How can i make the client side of the application search the network for the server socket? Right now i am getting the input from the user itself about the IP address and Port of the server.

Member Avatar
Member Avatar
+0 forum 4

hey. can i transfer pictures through sockets using c++? how can i do it if its posible.

Member Avatar
Member Avatar
+0 forum 1

Here is a simple code of chat between two peers. According to me, the code does what it should have but I am facing difficulty solving this SocketException error. This code worked fine till i made the last modifications. And now I am finding it difficult to trace the error. [CODE] import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.*; import java.util.*; import java.net.*; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; public class UDPchat extends Thread implements ActionListener { JFrame f; JPanel p; JTextField text; JButton b; JTextArea ta; private final static String newline …

Member Avatar
Member Avatar
+0 forum 3

I'm trying to understand socket programming in python by experimenting a little. I'm trying to create a server that you can connect to by telnet and that echoes what you type in the telnet prompt. I don't want to start using threads just yet. This is my code. [CODE]import socket host = "127.0.0.1" port = 8080 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind((host,port)) sock.listen(1) remote, address = sock.accept() print "Connection from", address while True: data = sock.recv(1024) remote.send(data) [/CODE] The server starts without errors, but when I connect with the telnet client I get, on the client side: [ICODE]> telnet 127.0.0.1 8080 …

Member Avatar
Member Avatar
+0 forum 4

The End.