C/C++ :: Send And Recv In Winsock2
Aug 4, 2014
so im just getting into network programming and im trying to make a chat server and client so i can send and receive messages. I have written both a chat and a client, with no error reporting (i know, i know). But the message that comes through on the server side is "hiiinaovH+". Ive represented this as well as i can but really they are non alphabetic symbols coming through.
client code:
#include <iostream>
#include <winsock2.h>
int main()
{
[Code]....
View 13 Replies
ADVERTISEMENT
Dec 2, 2014
My first time programming sth in Network. I have to use C to send a file to another PC, well COM port are useful but I didn't find how to refer to the address of my destination.
View 4 Replies
View Related
Apr 1, 2014
i developed 2programm that the first one is in C and the second one is in c#.and now i have to send some string text from c to c#.how can i do that in c ?
View 8 Replies
View Related
Apr 9, 2013
I'm connecting to my website through sockets, like this:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include <string.h>
int main(int argc, char *argv[]) {
WSADATA wsadata;
if (WSAStartup(MAKEWORD(2,2), &wsadata) == -1)
[Code]...
I want to send GET to a certain web page. How can I do that?
View 2 Replies
View Related
Mar 6, 2015
how to send datapackets. When we send a data packet from device to another, say I have a "string". How Do I send it? Are data sent as a hex or binary number?If so do i first convert the "string" into hex or binary and then send it over the communication medium(say UART)??
I have two hex numbers to be sent using the UART, do i wrap it in some specific form and send it and retrieve it on the other side?Say if I have a data structure, in that case how do i send it? Sending data packets is very cruicial in an embedded system.
View 3 Replies
View Related
Sep 3, 2014
I am writing a client-server program in C++ using C libraries. The server listens for a connection and when one is found, it is supposed to send a binary file(an image in my case) to the client. The server is sending the binary file perfectly after opening it and reading its contents into a buffer that is dynamically allocated in the SERVER file.
The problem begins when the client file is supposed to recv() the file, I do not know how I can allocate a buffer big enough for the file to be received. I know how to use malloc() and new, I prefer malloc() for executable size customization. Assuming the file being sent is 11000 bytes(note that this is an assumption and the client can not know the file size because the file size is dynamically generated by server).
How can the client generate a dynamically allocated buffer big enough to hold 11000 bytes?
OR
How can the client store the data in a buffer using recv() without knowing the file size.
Below is part of the code that does the send()'ing and recv()'ing.
SERVER
FILE *img = fopen("img.jpg", "rb");
fseek(img, 0, SEEK_END);
unsigned long filesize = ftell(img);
char *buffer = (char*)malloc(sizeof(char)*filesize);
rewind(img);
// store read data into buffer
[Code] ....
This outputs all the binary code perfectly but it is a bug because it can't be written to a file. Is there a way to dynamically increase the buffer until all filesize is received? Certainly, buffer needs to be dynamically allocated or program crashes ...
Also one more thing, when I telnet the server from command line, telnet displays all the output perfectly as well
Maybe telnet is storing data into a buffer behind the scenes, if so, how?
View 9 Replies
View Related
Jul 3, 2014
I was wondering if there was a way for me to send information, say a username and password, to a webpage via a c++ function. I was unsure how exactly to word it, but I did attempt to google it. Here is an example of what I mean.
App starts -> goes to "Https://www.my-site.com/?user=$username&password=$password" -> username/password is valid -> logs them in on desktop app
I do not know much about php, but I am assuming the ?user=$username is setting a variable, correct? I am familiar with sockets, but it seems using the above method, this could be possible without sockets, would it?
Important part:
That is the method that minecraft uses to login players, the question here is what function could I start to send the desktop app to the webpage.
EDIT:: After looking a little more I find that it is probably not possible without sockets, which is fine; however I don't know how to do it still, I would prefer to not use external libraries, such as Curl.
View 3 Replies
View Related
Mar 10, 2014
I'd like to be able to output sound over skype as if it were coming from my headset, how would I go about this?
View 1 Replies
View Related
Oct 12, 2014
I've been trying to send a command to another form, but it didn't work. Here's what I've done:
Form1:
I have a listview.
Form2:
I have a textbox and button.
I want to write something on the textbox from Form2, click on the button and let it appear on the listview on Form 1.
Here's my code, but doesn't work />
Form1
public void UpdateListBox(string data) {
ListViewItem lvi = new ListViewItem(data);
listView1.Items.Add(lvi);
}
Form2
private void button1_Click(object sender, EventArgs e) {
Form1 frm1 = new Form1();
frm1.UpdateListBox(textBox1.Text);
}
View 14 Replies
View Related
Sep 15, 2014
So I'm trying to send 2 keystrokes to a certain program. Let's say I would like to send the keystroke "1" twice, to notepad.
View 7 Replies
View Related
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
Mar 3, 2014
i've a function to add many buttons to TabbedPanel like is visible here
public void AddBeverageDrinkstoTabbedPanel(TabPage tp1, ListBox lst1) {
food getbeverage = new food();
string[] bev_product = getbeverage.name1;
FlowLayoutPanel flp1 = new FlowLayoutPanel();
flp1.Dock = DockStyle.Fill;
foreach (string value in bev_product)
[code].....
What happens? When i click in any button, want add an specific text to listbox and to do this i builded an method called beverageclick(), with these code:
public void beverageclick(object sender, EventArgs e) {
Button b = (Button)sender;//button sender
string value = (string)b.Tag;// value = b.tag (tag of sended button tag = value (value of AddBeverageDrinkstoTabbedPanel) method)
[Code] ....
What is wrong? how can i add an specific value when an button was clicked.
View 1 Replies
View Related
Dec 27, 2012
i am doing a structure program "struct book",but at the time of run cmd is opening and i am getting 'windows don't send' error and program has been terminating.
the code is following:
#include<stdio.h>
#include<conio.h>
display();
struct book
[Code]....
View 3 Replies
View Related
Apr 7, 2015
I have an assignment where I have to alter a ppm image and send it to a function in another file to print the new altered version.
#include "transform.h"
int main (int argc, char *argv[]) {
// declarations here
FILE *inFile;
// open input file
inFile = fopen("tiger.ppm", "r")
[Code] ....
View 1 Replies
View Related
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
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
Aug 10, 2013
I want to print the output of a c programme to a printer. Operating system is MS Windows xp sp2. This is the programme:
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
printf("
Hello Chandan2... ");
getch();
}
The output "Hello Chandan2..." is to be printed in printer, when i run the programme , but how to do it?
View 6 Replies
View Related
Nov 11, 2013
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?
View 11 Replies
View Related
Jul 30, 2014
I'm learning C++. Is there some way to make program function on input from a port like usb port and can I send bits through the port? For example A usb cable connected to a circuit. I press a button and an AND gate on the circuit gets activated by a bit from the usb port and a fan in the room turns on.
View 1 Replies
View Related
Apr 8, 2014
I have a function which send a string as argument to a txt file, like the following:
void Fprint(... ofstream& myfile, const string a, const int b)
......
myfile << "name: " << a << " age:" << b << "" << endl;
......
}
However, my IDE (msvc12.0) popup an error about the << before a, by citing "No operator matches these operands.
View 2 Replies
View Related
Sep 15, 2014
how do i send post with data to a php page on the net using c++? im using this for a file uploading site for my school group. and also, im planning to pass this as my project. but, i cant find a concrete way on how to send post method with data to a php page. ive been fed up with a lot of answers from the net, yet, each time i try to use them, i get errors. ive tried every library you can see till the third o of google. ive also tried a wrapper from this site, but, ive got no succes. im using dev c++.
View 5 Replies
View Related
May 30, 2014
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.
View 1 Replies
View Related
Jan 12, 2015
In my MainWindow I have a UserControl called CamAccessLevel1. This will be one of a few different UserControls which will have more and more functionality to a device as the Level goes up.
Each of those functionalities are themselves a UserControl, so that I don't have to keep remaking them for each different "Level" that I make.
So... I have a UserControl in a UserControl in my Mainwindow. My first goal is to have a button in one of those sections send an event back to the MainWindow to close the application. This sections is called "ProgramControl", as it has functions that relate to the program itself.
I can't seem to set a datacontext within another datacontext -> There is an error in UIViewModel below...
Note that I have replaced my company name with [snip]
In my Mainwindow.xaml
<views:CamAccessLevel1 x:Name="UserInterface"/>
Mainwindow.xaml.cs
public partial class MainWindow : Window {
#region MyModel
[code]....
View 10 Replies
View Related
Oct 26, 2014
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]....
View 3 Replies
View Related
Sep 8, 2014
I'm trying to send a simple text string using httpsendrequest, everything works fine, the string is sent but I don't know how to retrieve it in the PHP server. Also when I use internetreadfile, the dwBytesRead is 0 meaning that there is no response from the server though the application works fine. This is the code that I have so far.
#define _WIN32_WINNT 0x600
#include <stdio.h>
#include <wininet.h>
#define BUFLEN 200
static const char *acceptTypes[] = {"application/x-www-form-urlencoded", NULL};
static const char *postData = "teststr=Hello+world&testval=42";
int main() {
HINTERNET hSession, hConnect, hFile;
[code].....
View 1 Replies
View Related
Feb 27, 2013
Share ur code wit my. m working on windows n using visual studio 2008..
View 1 Replies
View Related