Click here to Skip to main content
15,896,412 members
Home / Discussions / C#
   

C#

 
AnswerRe: How can i know what is the bitmap color size of each pixel ? Pin
_Erik_11-Nov-10 1:46
_Erik_11-Nov-10 1:46 
Questionhow to generate toolstrip like glossy sky blue color for my forms back color? Pin
Tridip Bhattacharjee10-Nov-10 18:58
professionalTridip Bhattacharjee10-Nov-10 18:58 
QuestionDetecting display setting change like dual display ,resolution change etc. Pin
HalliHaida10-Nov-10 18:26
HalliHaida10-Nov-10 18:26 
AnswerRe: Detecting display setting change like dual display ,resolution change etc. Pin
Luc Pattyn10-Nov-10 23:37
sitebuilderLuc Pattyn10-Nov-10 23:37 
AnswerRe: Detecting display setting change like dual display ,resolution change etc. Pin
_Erik_11-Nov-10 0:05
_Erik_11-Nov-10 0:05 
QuestionNo problem.. just more of "What would you do" question.. Pin
Jacob D Dixon10-Nov-10 11:14
Jacob D Dixon10-Nov-10 11:14 
AnswerRe: No problem.. just more of "What would you do" question.. Pin
_Erik_11-Nov-10 0:44
_Erik_11-Nov-10 0:44 
GeneralRe: No problem.. just more of "What would you do" question.. Pin
Jacob D Dixon11-Nov-10 3:58
Jacob D Dixon11-Nov-10 3:58 
Ill read the Flags attribute.

I have to be able to send the client agents commands to perform which will return data to the server. From there I plan to have a control panel application that will view that information and also be able to send commands to the agents.

Now the agents could be on different networks. Which means that the server cannot create a direct connection to the agents due to them possibly being behind a firewall. So the agent of course has to be the one that first connects to the server.

I guess what I'm asking is if you were creating something like this how would you lay it out? I created the Operations class because it can hold the information, but it doesn't mean that ALL the information will be populated.

Sorry if I'm not explaining it very well.. lets me try it this way:

Client Agent connects to server
Server Accepts connection and queries database for pending actions:
Socket old = iar.AsyncState as Socket;
Socket client = old.EndAccept(iar);

// Create Operations objects
Operations[] ops = AgentActions.GetPendingOperations(1);

MemoryStream ms = new MemoryStream();
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(ms, ops);

// Send our serialized object back to client
client.BeginSend(ms.ToArray(), 0, (int)ms.Length, 0, new AsyncCallBack(SendCallback), client);


The pending actions table is just the AgentId and the TaskId (which matches the ENUM).

So at this point the client is receiving information from the server about what actions it should perform:
// (RECEIVECALLBACK)
int bytesRead = client.EndReceive(iar);
if (bytesRead > 0)
{
  state.ms.Write(state.buffer, 0, bytesRead);
  if (bytesRead == StateObject.BufferSize)
     client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReceiveCallback), state);
  else
  {
     state.ms.Seek(0, SeekOrigin.Begin);
     IFormatter formatter = new BinaryFormatter();
     Operations[] ops = (Operations[])formatter.Deserialize(state.ms);
    
     // from here we go to query the data (Running services, processes, computer information, etc..)
     
     // Once we have that information we send it BACK to the server so the server can store in the DB
  }
}


Here is my state object:
public class StateObject
{
    public Socket workSocket = null;
    public const int BufferSize = 1024;
    public byte[] buffer = new byte[BufferSize];
    public MemoryStream ms = new MemoryStream();
}



I hope that helps in explaining what I'm trying to do. Like I said it works. I can send the Operations array back and forth and insert it in the DB and what not but I'm just wondering if there is another way I should be doing this.
GeneralRe: No problem.. just more of "What would you do" question.. Pin
_Erik_12-Nov-10 3:14
_Erik_12-Nov-10 3:14 
GeneralRe: No problem.. just more of "What would you do" question.. Pin
Jacob D Dixon12-Nov-10 5:30
Jacob D Dixon12-Nov-10 5:30 
GeneralRe: No problem.. just more of "What would you do" question.. Pin
_Erik_12-Nov-10 6:01
_Erik_12-Nov-10 6:01 
GeneralRe: No problem.. just more of "What would you do" question.. Pin
Jacob D Dixon12-Nov-10 11:30
Jacob D Dixon12-Nov-10 11:30 
GeneralRe: No problem.. just more of "What would you do" question.. Pin
Jacob D Dixon14-Nov-10 14:23
Jacob D Dixon14-Nov-10 14:23 
GeneralRe: No problem.. just more of "What would you do" question.. Pin
_Erik_15-Nov-10 3:33
_Erik_15-Nov-10 3:33 
QuestionMonitor the phone state Pin
hoi110-Nov-10 10:39
hoi110-Nov-10 10:39 
Questionsending arguments to "Save As" Dialog box Pin
igalep13210-Nov-10 4:31
igalep13210-Nov-10 4:31 
AnswerRe: sending arguments to "Save As" Dialog box Pin
musefan10-Nov-10 5:56
musefan10-Nov-10 5:56 
AnswerRe: sending arguments to "Save As" Dialog box Pin
Richard MacCutchan10-Nov-10 6:19
mveRichard MacCutchan10-Nov-10 6:19 
GeneralRe: sending arguments to "Save As" Dialog box Pin
igalep13210-Nov-10 10:09
igalep13210-Nov-10 10:09 
GeneralRe: sending arguments to "Save As" Dialog box Pin
Richard MacCutchan10-Nov-10 22:36
mveRichard MacCutchan10-Nov-10 22:36 
GeneralRe: sending arguments to "Save As" Dialog box Pin
igalep13210-Nov-10 22:49
igalep13210-Nov-10 22:49 
GeneralRe: sending arguments to "Save As" Dialog box Pin
Richard MacCutchan11-Nov-10 1:19
mveRichard MacCutchan11-Nov-10 1:19 
GeneralRe: sending arguments to "Save As" Dialog box Pin
igalep13211-Nov-10 4:31
igalep13211-Nov-10 4:31 
GeneralRe: sending arguments to "Save As" Dialog box Pin
Richard MacCutchan11-Nov-10 5:07
mveRichard MacCutchan11-Nov-10 5:07 
AnswerRe: sending arguments to "Save As" Dialog box Pin
Luc Pattyn10-Nov-10 10:24
sitebuilderLuc Pattyn10-Nov-10 10:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.