C# :: Sending File Over TCP

Sep 16, 2014

why this code works only for file of smaller data. When I try to send for istance a image, the image arrive corrupted.

Client:

//read all file
byte[] vett = File.ReadAllBytes(s);
//read filename

[Code]....

View 11 Replies


ADVERTISEMENT

C++ :: Sending Data From A File Via Winsock?

May 11, 2013

I want to send data from a file via winsock. The problem is that the only first line in the file is send.

Client

#include <iostream>
#include <winsock2.h>
#include <fstream>
#include <string>
#pragma comment(lib,"ws2_32.lib")
#define SERVER "127.0.0.1" //ip address of udp server

[Code] ....

View 2 Replies View Related

C# :: How To Delete Attached File After Sending Mail

Jul 21, 2013

I use SmtpClient's SendAsync method,when after send mail, i delete the file ,tip The process cannot access the file because it is being used by another process.

System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
SmtpClient client = new SmtpClient();
string attachmentPath="c:\test.jpg"
if(attachmentPath != "") {

[Code] .....

View 4 Replies View Related

C++ :: Sending Constants As Parameters

Nov 21, 2013

What's the problem with the following:

Code:
#define K 3;
int max(int a, int b) {
return a>b? a : b;
} int main() {
cout<<max(K, K+3);
return 0;
}

Why is it not allowed, and how is it different from:

Code:
int max(int a, int b) {
return a>b? a : b;
} int main() {
cout<<max(3, 3+3);
return 0;
}

View 3 Replies View Related

C :: Sending A Packet Over Sockets

Oct 30, 2013

I have a socket connection already set up, my thing is what would be the best way to send a packet through sockets? My teacher wants us to convert the packet to bits first before we send it. I think he wants something like this:

Code:
struct packet{

int header
int message
int flag

}clientpacket; m

My question is how do we covert this to bits, before sending it. One of my friends said we can create a char[] array the size of the struct as a buffer. will memcpy() change the struct to bits if I copy it to the buffer?

this is how is suppose to look in bits for the header field/column.

Field : header
Field size(bits): 8
data format: Unsigned int
value example: 1
Value in bits: 0000 0001

I am confused, I think I send a structure over the socket but I did not convert it to bits before I sent it .

View 13 Replies View Related

C :: Sending Matrix Over UDP Socket

May 18, 2014

I want to apply program to send matrix from client and server ,and return back a processed matrix ..

How I can do it using UDP ,it was easy to use tcp for that!?

View 3 Replies View Related

C :: Sending Integer Via Socket

Dec 18, 2014

Verify my Method . I am not getting expected output ..

Code:

int Amount=500;
send(newSocket,Amount,4,0);
close(welcomeSocket);
recv(clientSocket,Amount,4,0);
// Amount= ntohl(Amount);
printf("Data received: %d",atoi(Amount[0]));

View 5 Replies View Related

C :: Sending Numbers Through Sockets

Nov 1, 2013

I want to write a program(s) so that the client sits and waits for a scanf to receive an int, then send to server, server then receives the int, processes it, then goes back to sit and wait for new input. to start with, where do i start! server side, or client side? and also what order do i have to go in my program before the loop to set up the socket, and listen? and then what gets looped to keep the connection open and wait for new receive?

View 4 Replies View Related

C++ :: Sending A String To Program?

Jul 21, 2013

I have a project, to make a program that spams chat programs. I've been trying to figure out how to send a string to an open program such as notepad, or a chat window. I know how to simulate keystrokes but I have yet to figure out or find out any way of sending a string to a program. pseudo code:

int main() {
string a;
int howManyTimes;
cin >> a;
cin >> howManyTimes;
//user enters "pizza"
for(int i = 0; i < howManyTimes; i++) {
//now I want "pizza" to be sent to the program keystroke enter or whatever the correct syntax is sleep
} }

View 1 Replies View Related

C++ :: Template Of Sending Text

Mar 1, 2013

I am writing some code to send text to a third part software. Basically each sending looks like this:

p << "set terminal eps
";
p << "set output '07.eps'
";
p << "plot '-' using ($1 == 0 ? NaN : $1) with lines linecolor 2 title 'comparison ratio',
'-' using ($1 == 0 ? NaN : $1) with lines title 'comparison ratio'
";
p.send(TOex_ar).send(TOnew_ar);
p << "set terminal wxt 7
";
p << "plot '-' using ($1 == 0 ? NaN : $1) with lines linecolor 2 title 'comparison ratio',
'-' using ($1 == 0 ? NaN : $1) with lines title 'comparison ratio'
";
p.send(TOex_ar).send(TOnew_ar);

Each time I have to change the number "07" and "7";decide to add or not the following parts: "using ($1 == 0 ? NaN : $1)", "with lines", "linecolor 2";and write the title 'comparison ratio' and the name of data to send "TOex_ar" and "TOnew_ar".Since I have to do this kind of thing 50 times in my code, and it is in the form of text, I am wondering whether in C++ we can write a template or function to simplify the program, just to input the changing parts.

View 3 Replies View Related

C# :: Sending Messages To Log In And Password

Apr 20, 2014

I wanted to make an program which is sending messages to log in and password, but instead of message it gives me "System.Windows.Forms.TextBox, Text: AND HERE MY TEXT I WANTED.

View 9 Replies View Related

C# :: Sending X-AMF Type Packets

Jan 10, 2015

create BOT that adds friends on one of Chat websites.

Im using C#

On website there is a button that adds user to friends

<li class="friend"><a href="javascript:void(0)">Add Friend</a></li>

I captured packet that is sended to server then that button is clicked

POST (info hided)/amfgateway.php HTTP/1.1Host: (info hided)
Connection: keep-alive
Content-Length: 52

[Code].....

It apears that this is AMF(Action Message Format) type packet Content-Type: application/x-amf it is in binary and this complicates things a little because I cannot send it with regular httpwebreqeuest class(Or I think so)

I used Fiddler4 with AMF plugin to check what data was passed with that packet

It apears that these numbers under content / 0 are User-id that is needed to add user to friends

I did a research with little success finding any usefull examples. I just found that there is a library for FLEX/FLASH remoting called fluorinefx and this should do the job but when I opened documentation it seems little too complex for me.

View 2 Replies View Related

C++ :: Sending And Receiving Data?

Jul 23, 2014

If I have a text file named, stuff at a specified path in the c : drive, how do I send the contents of this file to another computer using the Internet?

View 5 Replies View Related

C :: Function Not Sending Back Values

Nov 4, 2013

I am trying to get all these functions work together and send the value of countX and countY back into main from function2() and function3() to be used by function4() later on.. But I keep getting 0 printed out and I am not quite sure why.

Code:

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define maxrow 20 //defines maxrow as a constant of 20
#define maxcol 30 //defines maxcol as a constant of 30
}

[code]....

View 2 Replies View Related

C++ :: Inserting Hex Value And Sending It At Serial Port

Dec 17, 2013

I am trying to convert decimal value 1 to 32 to hex value and insert it at 4th pos of char array and send it as hex value at the serial port .

My issue is it is converting to decimal to hex value but when it sends, it treat the converted hex value as char and sends it equivalent hex value.

For example

if decimal =1 then its hex = 1.
so , writebuffer[3] =1

But when we send whole writebuffer through send function, it treat this 1 as char and sends its hex value as 31. how to send its hex value.

unsigned int i=0;
char hex[3];
unsigned char hexunsigned[3];
unsigned int dec;
do {
unsigned char writebuffer[8] ={0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

[Code] ....

The send function is

void serial::send(unsigned char data[], DWORD noOfByte) {
DWORD dwBytesWrite;
WriteFile(serialHandle, data, noOfByte, &dwBytesWrite, NULL);
}

View 2 Replies View Related

C/C++ :: Sending Char And Storing It In Vector

Feb 3, 2014

I've got something I'm trying to accomplish, but crashes my program.

I've got my server and client code.

Having the client send a message they type (char Chat[1024]) And the server receiving the chat (char recv_chat[1024]) only to send it to all connected clients again. Which the server sends the recv_chat.

The client receives it (char recv_chat[1024]). This works, and the client gets the right info. However, I'm trying to store it using a vector. I'm sure I've tried any way possible.

Client storing vector pseudo-code:

vector<char*> SaveChat;
int main () {
while (true) {
if (newClientConnected) {

[Code]....

This doesn't work, and crashes my application. I've tried changing the vector to string, const char*, basically anything I can with no avail.

View 8 Replies View Related

C# :: Filling And Sending A POST Form

Mar 21, 2015

I'm building a project in my free time and in the last part of it I need to fill a form of a website and then 'hit submit', but how it can be done. Btw the form is a 'POST' form so it's harder than a 'GET' one.

View 2 Replies View Related

C/C++ :: Sending Data To USB Port In Ubuntu?

Apr 21, 2014

How to send a keystroke or a mouse event to another running process in Ubuntu? I want to write a C program that reads data from the USB port sent by AVR Micro Controller board continuously.In response to that it checks the data received and sends a command to another process running on the computer? Example,when the program reads 101 from the USB port it sends left mouse button down to the VLC media player window that is currently running?

View 1 Replies View Related

C/C++ :: Schedule Sending Of Messages From A Process

Mar 18, 2015

I am new to this area and have the requirement like:

1) A running process wants to send message based on event arrival.

2)the process checks if event is critical

3)if critical then it has to send message immediately ,else send after time t.

4) The process is continuously process the events . so once it knows the event is not critical and has to send message later it has to proceed with its normal operation.. only when time 't" comes it has to come and send message.

View 4 Replies View Related

C# :: Sending Input To Specific Window

Feb 18, 2014

I have some experience in C# and choose the project of a "rapidfire script". It is a program, which shoot rapidly in a FPS by sending a "left-mouse-button-click" over and over again while the "real" left mouse-button is down.

Now, I tried multiple ways of sending the left mouse button but none of them worked the way I wanted them to. I tried SendMessage, PostMessage and mouse_event. One of them made the window unresponsive, another only pressed the mouse button while I was still moving the mouse and another didn't work at all.

I know a script which does exactly that and is coded in AutoHotKey. AHK is open-source but since I am not familiar with C++, it is very hard for me to understand what exactly is going on here:

AutoHotKey: keyboard_mouse.cpp

And here is the AutoHotkey-Script: AutoHotKey - pastebin.com

And my current code. The input delay is very irregular and strange. Sometimes the real "right mouse button click" gets ignored and I don't know why.

if (State == RapidfireState.ACTIVE) {
// Check if the left mouse button is down. If it is, send fire commands to the game
if (MouseDown()) {

[Code]....

View 2 Replies View Related

C# :: Prevent Sending Multiple Emails

Dec 10, 2014

I have some code which triggers an alarm when an ascii number is read in on the com port:

In that code, i have it send an email to let me know i have an alarm. The problem is it keeps sending the email over and over until i cancel the alarm. Inbox gets full real quick!

Im having trouble implementing a way to send the email just once! Ive googled as much as i can find but i cant get any way to work.

//QT TANK TEMP TOO LOW:
if (ALARM_TYPE_Value == "5") {
ALARM_TYPE_tb.BackColor = Color.Red;
ALARM_TYPE_tb.Text = " **ALARM**" + Environment.NewLine + " ";
ALARM_TYPE_tb.Text += "

[Code] ....

View 4 Replies View Related

C/C++ :: Winsock Sending X264 Nal Unit

Mar 13, 2015

I am currently trying to send a x264 nal unit using WINSOCK with a reliable multicast socket. It isn't decoding properly, and my initial thought is I am not receiving all the bytes correctly. I was hoping some fresh eyes can provide insight on errors or any improvements. I have seen some topics about this subject, and they showed sending entire structs with the socket. However, I am concerned about endianess so I am trying to stay away from that approach. I have commented out the decoding part, until I am confident that I am receiving the nal unit properly.

Server:

#include <WinSock2.h>
#include <WS2tcpip.h>
#include "wsrm.h"
#include <Windows.h>
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include "x264Encoder.h"

View 4 Replies View Related

C++ :: Sending Attachment Via SMTP (Gmail)

Jan 6, 2014

I need c++ code that can send emails with attachments via SMTP (Gmail). I haven't had any luck finding anything ...

View 1 Replies View Related

C++ :: Sending Variable Amount Of Data Over Winsock?

Oct 31, 2013

Client:

Code: ....
string cmd = "dir c:filequeue > ";
string outputFilePath;
outputFilePath.append(getTempPath());
outputFilePath.append(" est.txt");
cmd.append(outputFilePath);
system(cmd.c_str()); // dir c:filequeue > %temp% est.txt
string content = get_file_contents(outputFilePath.c_str());

send(s, content.c_str(), content.length(), 0); I'm executing the "dir" command to get a listing of Folders/files of one Folder. Then I read the Output of the file and send it over winsock to the Server.

Now, the Problem is, I don't know how I can handle the recv properly, cause I have to set the buffer size without knowing, how much data is actually transfered. Sometimes maybe no files are in c:filequeue, sometimes a 100k.

So I tried to make recv as a Loop:

Server:

Code: ...

while (rc != SOCKET_ERROR) {
printf("
#");
gets(buf); //please no discussion about gets, I will Change this later ;)
if (strcmp(buf, "ls") == 0){
send(connectedSocket, "LIST", 4, 0);

[Code] .....

now it works, but as the recv blocks, it will never leave the Loop, even when the Transfer is finished.What should I do?

I believe I could make unblocking sockets, but that's a bit complicated. Isn't there an easier solution, with malloc'ing the buffer or a Signal when to leave the recv Loop?

View 3 Replies View Related

C :: Sending Variable From Server To Client Program (with Ack)

Feb 23, 2015

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).

View 11 Replies View Related

C++ :: Sharing A Program - Sending Executable Files

May 22, 2013

I am just wondering if it is possible to send a project to someone via email - In a simple way, almost like you would install software from the internet, maybe a setup file, or something. The compiler I use "Dev C++" creates a .cpp file and an executable. Unfortunately, I cannot send that .exe file. How would you recommend sharing a program?

View 5 Replies View Related







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