473,396 Members | 2,093 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,396 software developers and data experts.

Client-Server communication problem with mailslot

I'm writing a client-server software which should emulate an email service
on a local machine. I'm now at the beginning and I'm trying to let
communicate the client and the server process, but have a problem with
GetMailslotInfo() in the server process inside the main() which returns with
error code 1 which means "Invalid Function" though it looks correct to me.

Can you understand why does that happen?

You can see the code here:
http://lacasa.altervista.org/software/Server_01.c
http://lacasa.altervista.org/software/Client_01.c
http://lacasa.altervista.org/software/input.txt
the last one must be inside the folder where you put the server process and
it is needed to use the "Read email" option.

That host doesn't support direct linking, then you have to copy and paste
the links into the browser address bar.
Aug 7 '07 #1
1 1954
"Alhazred" <a.********@email.itwrites:
I'm writing a client-server software which should emulate an email service
on a local machine. I'm now at the beginning and I'm trying to let
communicate the client and the server process, but have a problem with
GetMailslotInfo() in the server process inside the main() which returns with
error code 1 which means "Invalid Function" though it looks correct
to me.
You will have to ask in a Windows group about why GetMailslotInfo is
returning an error. This group deals with standard C.
You can see the code here:
http://lacasa.altervista.org/software/Server_01.c
http://lacasa.altervista.org/software/Client_01.c
I was looking to see if this was indeed Windows code, and I saw:

for( i = 0; (i < 99) && ((ch = getchar()) != EOF) && (ch != '\n'); i++ )
MyMessage[i] = (char)ch;
MyMessage[i]='\n'; // ritorno a capo
MyMessage[i+1] = '\0'; // termina la stringa
strcpy (request_message.req.da, MyMessage);

(and this pattern is repeated several times). The buffer MyMessage
and request_message.req.da are all arrays of size 100.

This is a convoluted way to put line from stdin into a buffer and in
all the convolution you have introduced a serious error. When the
input is long, the loop can terminate with i == 99. MyMessage[i+1]
invokes undefined behaviour when i == 99.

Every time you write a loop (for, while, do), invert the condition and
then look to make sure that the code following makes sense in all of
the cases that might terminate the loop:

!((i < 99) && ((ch = getchar()) != EOF) && (ch != '\n'))

implies that i == 99 or ch == EOF or ch == '\n' at the loop exit.

[Aside: your 99 should be calculated from the macro used to define the
arrays: MAX_DIMENSION - 1 and it should be '- 2' rather than '- 1', of
course].

Also, the above code is trying to do what the one line:

fgets(request_message.req.da, MAX_DIMENSION, stdin);

does.

--
Ben.
Aug 7 '07 #2

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

Similar topics

3
by: Rea Peleg | last post by:
Hello I'd like to use .NET framework namespaces in client side java script. For example i'd like to import System.Activator, in order to call Activator.CreateInstance() method inside a client side...
3
by: Prasad Patil | last post by:
Hi, I have a webform, The link on the webform should call the exe program installed on the client machine when the user click the link on the webform. It should run the exe installed on the...
1
by: Rhett | last post by:
Hello,EveryBody! I'm troubled by a design problem, Hoping that you'll save me out! The Situation is: We have two project of code A and B.A is our reusable code base, B is for specified for...
4
by: Mike D | last post by:
I want to connect to an oracle database from my client pc, OS is win2k or XP. Can I connect to an oracle database without having the full oracle client installed? If so what would be the minimum...
1
by: Friends | last post by:
Hello sir, I have a problem in calling a exe from client machine.. This is my Problem there is an exe in client machine i need to call the exe from web page..In that page there will be button if I...
1
by: Mike9900 | last post by:
I want to use an interface in both the webservice and its client. For example, the web service implements an interface and then the client cast that webservice to the inteface. It seems impossible,...
11
by: pshindle | last post by:
We have several machines currently running the DB2 V7 Run-time Client that we would like to actually be running the App Dev Client. To 'upgrade' (within the same version) this client software can...
0
by: thatsMaBoy | last post by:
Hi, I have a VB.NET 2003 web service client (EXE) that makes use of a SOAPExtension class. The client calls a web service that returns a SOAP message containing MIME encoded files. The...
1
by: acmlir | last post by:
I have made the jump (yes I am slow) and am using WCF. I have a scenario where I need to be able to pass the client credentials from one service to another. The configuration is : client app, middle...
1
by: suzacaru7 | last post by:
HI, I am doing a database for my beutition shop. I created a table called slimming, which i store the clients info (including ID card number), the date of the appointment, the type of therapy...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.