473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

send() return -1 - Console application

I´m programming with Visual C++ since 1995. I have developed many client and server Windows applications using sockets and MFC. Now I need a Console Application to convert in a NT service and I´m sliding: I wrote a serverapplication and it accept connection from the cliente but, when it try to send data, send returns always -1...
Someone may help me pointing to a sample code with this kind of implementation?
TIA
Nov 17 '05 #1
3 1757
Hello

What does the WSAGetLastError() return?

I've made many console applications that uses winsock with no problems.

--
Elias
"Cesario Simoes" <Ce************@Digitro.com.Br> wrote in message
news:AC**********************************@microsof t.com...
I´m programming with Visual C++ since 1995. I have developed many client and server Windows applications using sockets and MFC. Now I need a Console
Application to convert in a NT service and I´m sliding: I wrote a
serverapplication and it accept connection from the cliente but, when it try
to send data, send returns always -1... Someone may help me pointing to a sample code with this kind of implementation? TIA

Nov 17 '05 #2
I forget this detail in my post... The result is 0... :-

m_uiStatus = WSAGetLastError()

m_uiStatus == 0... :-(
Nov 17 '05 #3
"Cesario Simoes" <Ce************@Digitro.com.Br> wrote in message
news:AC**********************************@microsof t.com...
I´m programming with Visual C++ since 1995. I have
developed many client and server Windows applications
using sockets and MFC. Now I need a Console Application
to convert in a NT service and I´m sliding: I wrote a
serverapplication and it accept connection from the cliente
but, when it try to send data, send returns always -1...
Someone may help me pointing to a sample code with
this kind of implementation?


It is hard to give an open-ended question like this anything more than a
general answer. Once you get to the point where you know what it is that
fails and how it fails you may want to post a short snippet of code that
exhibits a problem.

Until then, note that services (usually) run in a different security and
(usually) run on a different desktop. That can be the cause of problems.

I suggest that you take a look at the console-mode simple TCP/IP client
server sample in the Platform SDK named "simple" at the sub-directory

Samples\netds\WinSock\simple

Also take a look at the shell of a service at

Samples\winbase\Service

It is a simple service which uses a named pipe to handle client requests.
There are other samples and I think that there is an ATL service wizard in
some versions of VC.

Your mission is to marry the two samples. <g>

Regards,
Will



Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jas | last post by:
I have a basic client/server socket situation setup....where the server accepts a connection and then waits for commands. On the client side, I create a socket, connect to the server...then I...
2
by: Boba | last post by:
Hi, I'm programming a WinForm application. I would like to enter commands that will send output that will help me to locate bugs in the future. I know that there is a way to send output by...
4
by: zhimin | last post by:
Hi, I'm writing a program to send large file(100m) through dotnet using TCPListener & TCPClient, I'm sending the file with a ask and response loop: 1. Client send a flag 1 to server indicate it...
6
by: Tim Roberts | last post by:
I've been doing COM a long time, but I've just come across a behavior with late binding that surprises me. VB and VBS are not my normal milieux, so I'm hoping someone can point me to a document...
1
by: Joey | last post by:
I am using the below code to run a dos based program. While it is running you can hit ctrl-c to cancel the process. Does anyone know how I can send the same keystroke to the already runing...
3
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the...
0
by: Buddy Home | last post by:
There is two examples of code. Example 1. Send and Receive within the same process. Put this code in a console app called SendAndReceive and run the code. using System; using...
14
by: eliss.carmine | last post by:
I'm using TCP/IP to send a Bitmap object over Sockets. This is my first time using C# at all so I don't know if this is the "right" way to do it. I've already found out several times the way I was...
5
by: Markgoldin | last post by:
I am searching for a solution of sending messages from not .Net process into a .Net process written in C#. I have gone already thru sockets solution and have porblems with it. I am not a C# coder...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.