|
Nobody is going to be able to answer this question as we know absolutely nothing about your system and requirements. There are lots of ways to do this, but what you do is up to you and your research against your requirements.
|
|
|
|
|
Zeyad Jalil wrote: I need to make this product as a cloud service such as I will publish the web service on My servers and also publish the clients SQL databases on our servers and the clients only download the client application (Financial System) and install it on their PC's. Do you know what you want, or want to build?
A cloud service, has nothing to do with that much of hosting, downloading. A cloud service is a cloud service, you just publish once. There is not this much of a churn in the process and you provide not the application, but models; Saas, PaaS etc.
What you should focus on is SaaS. You would require to build it that way, then purchase any cloud subscription to get started and learn how they would support your needs.
Going cloud is of no use, if there is a lot of Ops going on everywhere.
Quote: Please let me know what is the best case to manage the clients accounts and registrations and what is the best solution for this.
Same, you have to think of these things first. On cloud, you are also provided an amount of data. But, what to purchase? 1) Relational database 2) No SQL database? That depends entirely on your data, your needs and your customers.
Share some more insights, so that we may guide you on this concept.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hello guys, i really need help for this
i'm writing in C# a client-server (not important maybe, but it's for a game), probably i need more knowledge and clarification about the process.
Firts of all, the process is the same for client and server, and EVERYTHING IS (+or-)WORKING.
My code should explain what i'm doing
new Thread(() =>
{
int i = 0;
while (true)
{
byte[] bytes = new byte[102400];
NetworkStream stream = client.GetStream();
int received = stream.Read(bytes, 0, bytes.Length);
Console.WriteLine("Packets: " + ++i);
var basepacket = TNetwork.Encaps.Deserialize(bytes, 0, received);
Thread.Sleep(1000);
}
}).Start();
But there are some points that i don't get.
1) If i Send packets quickly
while(spamtest)
bp.Send(stream, ...);
the other point doesn't process all incoming data if it is busy (send 1000, processed 200). How to solve? i won't lose informations. there are no a kinda of SampleAndHold system? How is possible that i'm losing tcp packets just cause the program was busy??
2) I tried to send some data of 2k over the network (with another pc) but i had no problems. MTU is 1500 so my endpoint should crash getting incomplete binary-serialized-classes ! No?
I'm going crazy. My implementation is ok or i'm missing something?
3) Maybe client.GetStream(); can i only write or read at once? If i write, can't read? neither with 2 threads?
4) Probably i have to separate the Send process to a Queue in another thread.
5) What does exactly the flush()? I need to use it? I tried with and without Flush() after stream.write no differences (autoflush is false).
6) if i let client spam 70.000 packets, at the end one of both crashes
Help me please, getting crazy. Thanks
modified 10-May-17 8:17am.
|
|
|
|
|
Your code shows some misunderstandings: the inner while loop will start many threads in very short intervals - likely long before any of the already started threads has finished its work. A short wait time in between may be appropriate.
Your comment
// Do works ... Consider that classes are shared between clients and servers
// so classes are Invoked ... is unintellegible. What is the problem you want to solve with that? And why do you think your solution does so?
Also, I don't see any use of int i = 0 .
The code may become better readable when you refactor the bodies of the threads into functions.
Also note that an exception in a thread may crash your program if you don't handle it inside that thread.
|
|
|
|
|
Hi, i have removed useless code.
Now you can see, with Thread.Sleep(1000) i lose a lot of packets (more time, more loss. ~1000sent, ~40received). The above sketch code is the receiver.
What can I do to avoid losing packets?
Yes i know about handle inside threads
Hope you can help me, Thanks
|
|
|
|
|
You put the thread that is receiving data to sleep for 1 second upon the receipt of data and you wonder why you're losing packets?
|
|
|
|
|
Yes, i lose packets anyway.. Without .Sleep i get 1000sent/800received.
Client and server are in the same pc actually
|
|
|
|
|
You should never have a Sleep anywhere in your network code.
Also, you're receive code seems to think that when a client sends a message, you get the entire message in one go without regard to a message potentially being split up into multiple Reads. You Read however many bytes are told you received and deserialize them, even if the message is incomplete. The next read will also fail to deserialize properly because now you don't have the first part of the message but you have the trailing end of it, not a complete message.
Your losing "messages", not packets. Those are two totally separate concepts and cannot be used interchangeably.
It would seems that your client and server code has no method of delineating messages from each other. Where in the stream of bytes read can your code determine that a new message has started? You should only try to deserialize the data when you are sure you have a complete message in the buffer. That's what you have to implement.
|
|
|
|
|
> You should never have a Sleep anywhere in your network code
Using Sleep only for the example to emulate a computational delay
You are right, i'm confusing packets and messages sorry and thank.
I missed to say that: if i send messages slowly, the receiver can handle all messages without any issues.
The problem is when i send more message than the receiver can handle. Maybe i'm mad, but i won't lose messages!
The strange thing is, if i send a 2KB message over the network, the message have to be splitted, right? Cause of MTU. i should receive 2 messages? I still receive one, no crashes. So i need clarity.
As i said in the main post, i get crash only if i send a lot of messages much quickly
modified 10-May-17 11:57am.
|
|
|
|
|
If a message exceed the data payload size of a packet on a pipe, it is broken into multiple packets. You cannot attempt to deserialize the data until all packets for the message have been received. You're current code doesn't do that.
Your server code has no method of telling a client that 1) data is coming and this is how many bytes to expect (header), the data itself, and a checksum to validate that the data is OK (if necessary). These things do not have to be separate messages.
The client should not attempt to deserialize the data unless it 1) saw the message header and knows how many bytes to expect, 2) captured the data in the buffer, and checksummed the data to make sure it was OK (if necessary).
If the client receives anything it doesn't recognize or too few/many bytes, it should not attempt to deserialize the data. It should (optionally) tell the server to resend the data and go back to waiting for a new header.
|
|
|
|
|
So you suggest to send 4 bytes that's the length of the message and a some bytes for the checksum, which protocol you suggest for the cksum? md5? there are something lighter?
I will do that (after fix message loss)
Any ideas to avoid loss of messages?
thanks for your time guys
|
|
|
|
|
Normally, I would start with a message delineation marker, say 3 bytes of 'F0', then a 32-bit message length, then then message. The checksum is options, but if it's used, that would be supplied after the message length and before the message. Typically, the message is going to be a variable length so it should show up last.
|Start of Message|Length in bytes|CheckSum|Message bytes...|
| F0 F0 F0 | 00 00 00 1A | F6 |data bytes... |
You don't get it. This may just fix your message loss because as your code stands right now, since you don't have any way of knowing when a message begins and ends, you have no way of knowing if the data you deserialize is valid! You could be deserializing the end bytes from the last message combined with the beginning bytes of the next message thinking it's valid when it's not.
|
|
|
|
|
Problem solved .. you were right when you said "you're receive code seems to think that when a client sends a message, you get the entire message in one"
Now everything works perfectly
public static void CopyStream(Stream input, Stream output, int MaxLength)
{
int read, totalread = 0;
byte[] buffer = new byte[81920];
while (totalread < MaxLength)
{
read = input.Read(buffer, 0,
(
((MaxLength - totalread) < buffer.Length) ?
(MaxLength - totalread) :
buffer.Length
)
);
if (read == 0) break;
totalread += read;
output.Write(buffer, 0, read);
}
}
modified 12-May-17 10:05am.
|
|
|
|
|
The usual "pattern" is that the client "asks" for data that the server then sends.
You seem to be arbitrarily shoving data at clients and then expecting them to somehow keep up.
Ever been force fed without choking?
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I need to send data arbitrarily over the time or period (like 20times per second), not ask-resp. I could switch to UDP, don't know yet.
> Ever been force fed without choking?
Maybe handle X requests, then drop the extras
|
|
|
|
|
You've got a bigger problem with UDP. Your client must be tolerant of lost or corrupted data. UDP does not guarantee delivery of any packet nor does it even guarantee the order in which they arrive!
|
|
|
|
|
Yes yes i know, udp maybe in the future. Now let's work on tcp
|
|
|
|
|
I have a submenu on master page which has two webforms(candidate and add new) in it.when I click on candidate page and do my work. then if I have to go to add new page then I have to click on menu and click on add new page. Is there any way if i click on add new page there should be link label on top of page that shows candidate page. So that if I click that It should take me to a candidate page.
It is an emergency any help would be appreciated
|
|
|
|
|
Member 13189268 wrote: It is an emergency In what way? But as to your main question, you can put links in any page you wish in order to switch from one to another.
|
|
|
|
|
Member 13189268 wrote: It is an emergency
Have you checked the airways? Pulse? Bleeding?
Do you require the Police, Ambulance, or Fire services?
Because I've checked here, and nobody can see an emergency anywhere...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
i have a small confusion that when we compare like == or equal function then both does the same job. u have a very basic question here.
see my program full code
int x = 1000;
int y = 1000;
if (x == y)
Console.WriteLine("Value is same");
else
Console.WriteLine("Value is not same");
if (x.Equals(y))
Console.WriteLine("Value is same");
else
Console.WriteLine("Value is not same");
if (object.ReferenceEquals(x,y))
Console.WriteLine("ref is same");
else
Console.WriteLine("ref is not same");
string s1 = "Hello";
string s2 = "Hello";
if (s1 == s2)
Console.WriteLine("Value is same");
else
Console.WriteLine("Value is not same");
if (s1.Equals(s2))
Console.WriteLine("Value is same");
else
Console.WriteLine("Value is not same");
if (object.ReferenceEquals(s1, s2))
Console.WriteLine("ref is same");
else
Console.WriteLine("ref is not same");
i know that this kind of checking if (x == y) is based on value but when i use Equals function then i saw Equals is also work like == operator....am i right ?
how to check the reference ?
if (object.ReferenceEquals(x,y))
Console.WriteLine("ref is same");
else
Console.WriteLine("ref is not same");
i saw in this case else portion execute........why because different memory is allocated for x and y ?
see more for string reference check
if (object.ReferenceEquals(s1, s2))
Console.WriteLine("ref is same");
else
Console.WriteLine("ref is not same");
in this scenario s1 and s2 ref found same which is not clear to me because s1 and s2 ref should be different because two are different variable so how s1 and s2 reference check become same?
i like to know what are the best process to know value and reference is same or not whatever data type we use may be string or integer or float etc. please some one help me to understand this.
one guy said string in dotnet is interned. what is the meaning of In .NET strings are interned ? interned or internal is same ?
please discuss with a example just to clarify the meaning of string is interned in dotnet.
thanks
tbhattacharjee
|
|
|
|
|
|
What gets me is that he's been here for 13 years, and he still knows nothing about development, and can't use Google ...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
"Artificial" intelligence.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|