C++ :: Using Same Socket For Second Send / Receive Giving No Result?

Jul 28, 2013

when I want to use the same socket connected to the host to send() and recv() for the second time, recv() will return 0 without anything in buffer. Basically I am doing:

1. connect to the website
2. send packets
3. receive packets
4. send packets again (I think this one is working since it's not giving me SOCKET_ERROR)
5. receive packets again (this one is returning 0 so as "connection closed")

source code: [URL] ....

as you can see, I have sock2, which when I use for second send/recv it's working fine, however I will do more communication, and having sockets for all of that and connecting them.

View 4 Replies


ADVERTISEMENT

C# :: Socket TCP Send / Receive

Jun 28, 2014

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace test {

[Code] ....

I don't know if this is a bug in Winsock or the .NET Framework but i need to fix this or workaround. Recently I was working on a networking class and this error is breaking everything.

If you add Thread.Sleep(1) after Send() call then "TCP Bug detected" doesnt get executed but its not a reliable fix.

View 7 Replies View Related

C++ :: Streambuf For Socket - Send / Receive Data

Mar 27, 2014

I am trying to make a streambuf for a socket, which will use either WinSock or POSIX sockets depending on OS. I understand about how to send and receive data via sockets, but I don't really understand how to put that into a 'streambuf'. What functions do I need to override?

View 7 Replies View Related

C :: HTTP Packet Generation And Send / Receive Via Socket

Dec 26, 2014

I have Build code for sending/receiving TCP Traffic over c Socket . Now I want t add HTTP Protocol to it .

After searching out on google ,one method I found which is by GET method to send a query to a server like google.com and request a page .

But ,Suppose I saved a HTML page in my directory how can I send HTTP packet via client/server in socket using this HTML page .

View 4 Replies View Related

C/C++ :: HTTP Packet Generation And Send / Receive Via Socket

Dec 27, 2014

I have code for sending/receiving TCP traffic over C socket. Now I want to add HTTP protocol to it. After searching the web, one method I found which is by GET method to send a query to a server like google.com and request a page.

But, suppose I saved a HTML page in my directory how can I send HTTP packet via client/server in socket using this HTML page.

Server side code:

sockfd = socket(AF_INET, SOCK_STREAM, 0);
bind(sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
listen(sockfd,5);
newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr,&clilen);
while (1)

[Code] .....

View 1 Replies View Related

C++ :: HTTP Response Receive Using Socket

May 18, 2014

I make a simple c++ http post request using socket and it is working fine. But how to get only the message of the response. Here is my receive code:

char buffer[1028];
recv(socket, buffer, sizeof(buffer), 0);
printf("%s", buffer);

Then here is the response that the http send back.

HTTP/1.1 200 OK
Data: Mon, 19 May 2014 12:46:36 GMT
Server: Apache/2.4.9 (Win32) OpenSSL/0.9.8y PHP/5.4.27
X-Powered-By: PHP/5.4.27
Coneten-Length: 28
Content-Type: text/html

All done! Do some stuff now. So what I want to try is get 3 things in this response and put them to string vector but how to do this. What I need is to parse the response and the 200 OK, 28 and All done! Do some stuff now. then put them to string vector.

expected result

response[0] = 200 OK;
response[1] = 28
response[2] = All done! Do some stuff now

View 2 Replies View Related

C++ :: Winsock - Receive / Send Sequences

Oct 25, 2013

I'm trying to understand winsock with c++. Let's assume I have a 2 working applications, one is the client and one the server:

Client: I can enter a command, for example chat or filetransfer, it will then switch into this specific mode where I can enter commands like uploading a file, send a message etc.

Client
Code: ....
while (rc != SOCKET_ERROR) {
printf("
#");
gets(buf);
if (strcmp(buf, "CHAT") == 0){
// start chat mode

[Code] .....

I'm in a recv/send loop and I'm using streams...so basically all the data is being sent/received there. Now, if I want to upload a file, I send a FILETRANSFER String to the server. Then I will probably need another loop that receives file requests from the client. The server will need more details about the file, like the path, name, size...

Now, my question is, what's the best practise for something like that? I'm having problems understand how I can send 3 different values from the server to the client and how he will receive them in the right order store them in variables. And also, after sending something to the server, in some cases, the client will have to wait for the server to answer.

Is there a good example of a similar application?

View 3 Replies View Related

C# :: How To Send And Receive Data From Serial Port

Aug 13, 2014

private void button1_Click(object sender, EventArgs e) {
serialPort1.PortName = "COM1";
serialPort1.BaudRate = 9600;
serialPort1.DataBits = 8;
serialPort1.Parity = Parity.None;
serialPort1.StopBits = StopBits.One;

[Code]...

In my project i have a serialport control and a button, there is no error but i want to know how actually this works, i want to send and recieve the data from the serial port don't know how to do it..

View 9 Replies View Related

Visual C++ :: Send Message - Receive / Respond

Jan 2, 2014

I have a problem in a c++ project. I have created a .dll file and hooked to an .exe

I want this .dll to make a ping or to send a message like hello somewhere, and IF ping or message doesn't receive an answer that's means the user has suspended-terminated this dll from the exe then the exe will close. How can i do that?

View 11 Replies View Related

C# :: Access SIM Cards And Send / Receive Messages Through PC Interface

Nov 2, 2013

I'm gonna start a project for my own purpose. In my project I need to access GSM sim cards and send & receive messages through a PC interface. What kind of GSM Interface support for my Requirements and in feature may extend Requirements. what kind of programming language will be simple for write an pc interface to access that GSM interface device.

View 6 Replies View Related

C/C++ :: How To Send Many Images Through Socket

Jun 25, 2012

I have written a socket witch send an image 256x256 and now i want to send many images and i don't know what loop to write to make the socket after have sent the first image to send another and not to write the same program many times for every image ......

this is the part that read the binary image

if( !(fp=fopen("Anemos.bmp","rb"))) {
            printf("Unable to load bin file: %s...
","Anemos.bmp");

[Code] ....

View 2 Replies View Related

C :: Send Information And Receive From External Command Prompt From Program?

Jan 10, 2014

How can I send information and receive from external command prompt from my program??. I want to run an external command prompt, a code that's is not mine, to send information to this command prompt, then make my program hit enter at the command prompt and then receive back information from the command prompt.

View 5 Replies View Related

C++ :: Send Two Or More Char Arrays Over TCP Socket (winsock)

Nov 21, 2013

send(sConnect, (userinput, key), 256, 0);

sConnect is already predefined as a socket

Key is a character array of [32]

Userinput is a character array of [256]

How can you send both of them at the same time using the send function without having to create a separate connection?

View 1 Replies View Related

C++ :: How To Send Yahoo Mail Using Basic Socket Program

Aug 6, 2014

I am trying to send yahoo mail using socket program.

Using the commands like ehlo, starttls, auth login, data,.,quit.

but starttls is error. yahoo close itself. one more thing i use this same method for gmail is working.

The problem is we must enable the ssl authentication. Like System.net mail in .net package smtp.enablessl=true. how i enable ssl authentication in starttls in c++ program

View 1 Replies View Related

C++ :: Giving Score To Correct Player

Jul 22, 2013

I have programmed a game where you guess a number (1-6) and if the number is equal to the random number then give the player score + 10. But if I have selected for example 4 players then if the game will give player 1 a score it gives player 2 a score instead? What can be causing this error?

Code:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int cube;
int number[4];

[Code] .....

View 6 Replies View Related

C++ :: Giving Audio Input To A Program

Sep 27, 2013

I want to give audio-input to a FFT code (KissFFT) written in C, on a real-time basis. While I can give a simple test signal (like sine wave) by writing the sine function as input, I am not sure how I should convert an audio-signal (e.g.: song) into a form that can be taken as input by the KissFFT C code.

View 3 Replies View Related

C++ :: Array / Pointer Giving Error?

Jul 20, 2013

The program should ask the user how many students were surveyed and dynamically allocate an array of that size. The program should then allow the user to enter the number of movies each student has seen.

#include <iostream>
#include <string>
using namespace std;

[Code].....

The problem I'm having is that where I declare movies = [numStudents]; the semicolon after the numStudents array is giving me this error - "error: expected a '{' introducing a lambda body".

View 2 Replies View Related

C++ :: Add And Minus From Text File Not Giving Right Value

Feb 5, 2014

I'm creating a bank system. So I know to make a deposit to the balance, which add ups what is the balance to i have add.

When i run the deposit function, its work well in some ways. If balance(text file) has the value 10, add i addSum 20, the balance will become 30, same as the text file will become 30. so its work well to add positive number.

double deposit(double balance){
double addSum = 0;
system("CLS");
cout<< "Welcome to deposit."<<endl;
cout<<"Enter a sum you wish to add to your account:";

[Code] .......

When I withdraw from 30 which is the balance, then i takeSum, for example i take away 30. The balance will become 30 - 30 = 0

When i make another withdraw from example -150, it will be -150.

Which shows correct.

But when i make a deposit from -150 and i addSum 130, the balance shows -500, and it should had been -20.

double withdraw(double balance) {
double takeSum = 0;
system("CLS");
cout<< "Welcome to withdraw."<<endl;
cout<<"Enter a sum you wish to take away from your account:";
cout << balance << '

[Code] .....

What is causing this problem, also when function deposit and withdraw close, it goes to readBalance function, should go to menu.

double readBalance(double balance) {
int option;
system("CLS");
cout<<"Welcome to balance."<<endl;
cout<<"Your balance is:"<<endl;

[Code] .....

View 1 Replies View Related

C# :: Random Numbers Giving Same Number

Jul 30, 2014

Not a major issue since I got this to work but for some reason both my random numbers are the same and not sure why ...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class ComputerAssistedInstructions {
private static Random rand1 = new Random();
private static Random rand2 = new Random();

[Code] .....

View 2 Replies View Related

Visual C++ :: Giving Values To All The Members?

Oct 15, 2013

Write a C++ program to implement the following description:

1. Define a global structure and name it GStruct with the following members:
a. X as integer
b. Y as integer.

2. Define a local structure inside the main and name it LStruct with the following members:
a. X as integer
b. Y[3] as GStruct

3. Inside the main declare two variables V1 and V2 of type LStruct.

4. Give values to all of their members by using input statement (cin).

5. If V1 equal V2 print "They are equal" else print "Not Equal".

#include <iostream>
using namespace std;
struct GStruct {
int x;
int y;
};
int main() {

[Code] .....

View 1 Replies View Related

C++ :: Dividing Two Floats Not Giving The Required Quotient

Jan 9, 2014

Im using the remquo function in the cmath library as follows:

int quotient;
double a = remquo (10.3, 4.5, "ient);

This gives the correct remainder (a = 1.3) and quotient (quotient = 2).

Infact about 50% of the answers are right when I play around, however, trying something like:

int quotient;
double a = remquo (2.25, 1.5, "ient);

yields an incorrect quotient of 2 and remainder of 0.

I do think this has something to do with float arithmetic. I recall tinkering with the float number 0.500 and that the CPU actually saves it as 0.50000000000000231. However if my suspicion of float arithmetic as the suspect is correct, I do not understand why a tenth decimal would make such a drastic difference as changing the quotient result.

View 10 Replies View Related

C++ :: Code Blocks No Longer Giving Any Useful Errors

Jun 8, 2013

I'm using Code:Blocks 12.11 on windows 7, with the built-in MinGW compiler. When I try and compile a program that has an error in it (misnamed variable, missing include, extra semi-colon somewhere, anything) instead of saying something about what went wrong it just has this:

Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)

Which is not particularly useful for debugging.

View 11 Replies View Related

C :: Can't Seem To Receive UDP Packets

Jun 2, 2013

I'm trying to get a UDP server working and just can't seem to get it to read in any UDP packets. I can see the packet coming in on the correct interface and port from tcpdump, but my program never logs that it got the data.

I just keep getting a log showing that my recvfrom timed out. I'm pretty sure I'm setting everything up correctly.

Code:
int create_listen_socket() {
struct sockaddr_in si_me;
int sock_fd;
struct ifaddrs * ifAddrStruct=NULL;
struct ifaddrs * ifa=NULL;
void * tmpAddrPtr=NULL;
struct timeval tv;

[Code] ....

View 1 Replies View Related

C :: Retrieve Information From A Website - Libcurl Not Giving Output

Apr 2, 2014

I am trying to retrieve information from a website [URL] .... and have written a C code as follows:

Code:
#include <stdlib.h>#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
int main(int argc, char* argv[]) {
/* Exit status to return */
int exitStatus = 0;

[Code] .....

The output of this program should be:
From To
4504111 B0LPF3
4504111 P62993

The first print option [printf("%s", url)] gives the url output as [URL] .... which on being manually pasted in any web-browser gives the correct output but the program fails to give the output.

View 1 Replies View Related

C++ :: Game Control - Organizational System Giving Errors

Jun 24, 2014

I'm making a game with the following class structure:

GameControl - The class that actually runs the game, with a while(!closed) // run the game loop.

State - A class that handles the state of the game, for example if the game is rendering the scene it would be in one state, and if it is rendering the menu, it would be in another.

ComponentManager - A class that manages all of the components of what is being done, for instance, the Scene class would contain a bunch of components handling the drawing of each tree, physics, the camera, etc. The manager will put them all together.

Component - A component of whatever is being done. A tree (and its rendering code) would be an example of a component of the scene. The camera would be another. The component does not necessarily have to be drawn, it could be handling something like physics (and would throw physics events to other components that need to move in a certain way).

The GameControl class has its loop, which would call the update function on the current State (there are classes that inherit State and override the update function of State).

In the update function of the base class "State", it would take all of the active ComponentManagers and update them. There are classes that inherit the base class ComponentManager and override its update function.

Each ComponentManager would update each of the Components that it owns.

This is the organizational structure that I came up with to make the game scalable and changeable . If, for instance, I wanted to add multiplayer at some point, I would add a class that inherits the State that controls the gameplay called "MultiplayerGameState". This would just add a new ComponentManager that inherits the ComponentManager that controls the player and all of the living things that are moving around. Then, the MultiplayerGameState class would recieve the multiplayer messages coming in and add other player Components for the other players.

My code is giving me various errors like "Forward definition of class State" and "Invalid use of incomplete type State". Unless I made some stupid error that I didn't catch, these are being caused by me including the classes in ways that some of the classes do not see the full definitions of the classes they need to see (because of the preprocessor directives preventing classes from being included multiple times.

Code: (Not implemented exactly as shown above, but I think the main difference is that the main class is not in GameControl, it's in OgreFramework.cpp)

The base classes: [URL] ...
States: [URL] ...
ComponentManagers: [URL] ...
Components: [URL] ...
The project: [URL] ...

My question is: is there a better way to implement my organizational system so that these errors don't occur?

View 1 Replies View Related

C++ :: Sum Of Diagonals Of Matrix - Program Giving Segmentation Error?

Jan 7, 2015

After entering the values of the matrix, it is giving me segmentation error. also "if possible", correct it

#include<iostream>
using namespace std;
int main()
{

[Code]......

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved